Closed ronnac closed 5 years ago
Do you mean like you have JSON like this:
{"timestamp": 1573127103425}
And then you'd like to get Clojure data like this:
{:timestamp #inst "2019-11-07T11:45:03.425Z"}
If yes, I'm not sure if jsonista is really the right tool for the job. You'd need to know which numbers you want to convert to instants and which ones should be kept as-is. Jsonista does not easily support decoding object members based on the keys. It's probably technically possible to do using modules, but I'd recommend using jsonista to parse json and then coercing the value using some other library.
Ok. I wrote myself a conversion function based on the tick library. I'll decide on a case by case basis which values to convert with it.
You could do this as a separate step usin malli & custom transformers can help to to derive the required transformation or spec-tools & coercion.
Could you please add an example for how to use the :modules parameter to decode (read-value) a time from unix epoch milliseconds to human readable or instant?