scala lift json: pattern match on unknown data? -


i have strange json cannot change, , wish parse using jsonparsen in lift.

a typical json like:

    {"name":"xxx",  "data":{         "data_123456":{"id":"hello"},         "data_789901":{"id":"hello"},         "data_987654":{"id":"hello"},   }} 

the issue keys data unknown (data_xxxxx, xx:s not known). bad json, have live it.

how supposed setup case-classes in scala able build proper structure when keys here unknown, structure known?

you can use map, , every value can jvalue too, representing unparsed json. example:

case class id(id: string) case class data(name: jvalue, data: map[string, id]) 

and then:

json.extract[data] res0: data(jstring(xxx),map(data_123456 -> id(hello), data_789901 -> id(hello), data_987654 -> id(hello))) 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -