java - How to transform string with objects and array indexes into json -


i receive program map string representation of elements:

map<string,string> properties = new hashmap<string,string>() {{     put("news[0].title", "title 1");     put("news[0].body",  "body 1");     put("news[1].title", "title 2");     put("news[1].body",  "body 2"); }}; 

i need render freemarker-template. in question

freemarker-flat-structure-of-passing-parameters-transfer-to-array-of-objects

we decided impossible parse kind of values in freemarker. freemarker can eval json.

so need know how transform map objects or json. need that:

{     "news": [         {"title": "title1", "body": "body1"},         {"title": "title2", "body": "body2"}                 ] } 

names of parameters in map unknown, not "news", not "title" , "body", don't know. may there libraries such purposes?

since using own language there, write parser it. it's not complex language after all. also, transforming json doesn't make sense, based on know problem. yes, ftl expression syntax , json syntax overlaps quite much. shouldn't parse inside ftl-s, parse language list-s , javabeans and/or map-s, , pass plain java object freemarker.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -