I have this JSON data object:
var dataObjects = [
{
"Name": "Date & Time",
"Type": "Date",
"Value": "2019-12-11"
},
{
"Name": "Activity",
"Type": "String",
"Value": "ADD"
}
]
I want to build a new JSON data array object out of this one except the new one has the date formatted from "2019-12-11" to "December 11, 2019".
Here is my attempt after googling around but I'm getting a lot of syntax error.
Please excuse my lack of knowledge in Typescript and Javascript, that's why I ask for help because something simple to you still gives me a lot of difficulties.
public FunctionA(dataObjects: any[]): object
{
let returnObj: any = {}
let returnObjArray: any = [];
for(let obj in dataObjects){
var dateValue = obj.Date;
if(obj.Type == "Date"){
dateValue = obj.Date.Format()
}
returnObj = {"Name", obj.Name, "Type": obj.Type, "Value": dateValue };
returnObjArray.push(returnObj);
}
return returnObjArray;
}
I sort of understand my error is that I somehow has to specify what is this "any" array before I can use its property. However, I tried declare it below and I still have error:
dataObjects: Array[{ Name: string, Type: string, Value: string }]