Convert JSON array containing nested content to List -
i have been tasked maintaining legacy scala application , have come across json parsing problem don't know how solve. need list of json objects nested inside json array. here json content looks like:
[{"name":null, "tags":[], "content":{ more nested json here }}, {"name":null, "tags":[], "content":{ more nested json here }, ...]
we using argonaut library our json parsing. if had following json:
val json = {"name":null, "tags":[], "content":{ more nested json here }
then use following code access content
json want:
val lens = jobjectpl >=> jsonobjectpl("content") val s = parse.parseoption(json) val content = lens.get(s)
and content
json object, access fields. however, actual problem need list of json objects, each object content
array. if wondering why need this, must validation of list against list of known , expected values.
the closest came solution in stack overflow answer:
mapping on json array argonaut
but lens operators did not work me, possibly due missing dependency not mentioned in answer or in argonaut/monocle documentation.
Comments
Post a Comment