I am a bit lost with jsonata and moment.
Input data example:
[
[1618243200000, 5.45, 5.45, 5.2, 5.2],
[1618257600000, 4.98, 4.99, 4.96, 4.96],
[1618272000000, 4.88, 4.88, 4.67, 4.69],
[1618286400000, 4.74, 4.81, 4.71, 4.81]
...
]
Without the use of moment, expression:
payload.{
"date": $[0],
"open": $[1],
"high": $[2],
"low": $[3],
"close": $[4]
}
Output:
{
"date": 1618243200000,
"open": 5.45,
"high": 5.45,
"low": 5.2,
"close": 5.2
}
All good.
Now I am trying to format the date with moment, expression:
payload.{
"date": $moment($[0]).format("D-MMM-YY"),
"open": $[1],
"high": $[2],
"low": $[3],
"close": $[4]
}
Output:
{
"date": ["12-Apr-21", "1-Jan-70", "1-Jan-70", "1-Jan-70", "1-Jan-70"],
"open": 5.45,
"high": 5.45,
"low": 5.2,
"close": 5.2
}
What is happening ? Is moment evaluating/referencing differently ?