Is there a way to decode arbitrary json (e.g: We don't know the keys at compile time)?
For example, I need to parse the following json:
{
"Foo": [
"Value 1",
"Value 2"
],
"Bar": [
"Bar Value 1"
],
"Baz": []
}
where the names and number of keys are not known at compile time and may change per GET request. The goal is basically to decode this into a Map String (Array String) type
Is there a way to do this using purescript-argonaut?
You can totally write your own by first parsing the string into
JsonviajsonParser, and then examining the resulting data structure with the various combinators provided by Argonaut.But the quickest and simplest way, I think, is to parse it into
Foreign.Object (Array String)first, and then convert to whatever your need, likeMap String (Array String):