I have a nested json whose structure is not defined. It may be different each time it starts, as I am reading from a deleted file. I need to convert this json to a map of type Map[String, Any] . I tried to look into json4s and Jackson parsers, but they don't seem to solve this problem. Does anyone know how I can achieve this?
Example line:
{"body":{ "method":"string", "events":"string", "clients":"string", "parameter":"string", "channel":"string", "metadata":{ "meta1":"string", "meta2":"string", "meta3":"string" } }, "timestamp":"string"}
The nesting level can be arbitrary and not predetermined.
To help use:
I have a [String, Any] map that I need to save to a file as a backup. So I convert it to json string and save to file. Now every time I get new data, I need to get json from the file, convert it to a map again and do some calculations. I canβt save the card in memory, as I would lose it if my work failed.
I need a solution that converts the json string back to the original map that I had before I converted it.
source share