0

I have this application where I read a sequence of JSON object ... say, j1,j2,...,jn and I need to transform them to j1',j2',...,jn' -- NOTE this is a JSON to JSON transformation.

At the moment I'm doing this through utility methods which traverse the first object and then compose the second object.

I'm reasonably happy with my approach, however it gets tedious. I was wondering if folks know of toolkits or code patterns to address this problem.

Thanks.

PS: For example I looked at XSLT a million years ago to solve similar problems with XML but I was not too enamored by XSLT ... is there an XSLT for JSON or a general purpose transform languages? -- NOTE: XSLT is cited as an analogous technology for XML -- I am NOT looking to transform JSON to XML or vice-a-verse.

PPS: I reckon I could use an ETL tool however I think this is a very light weight application and ETL would be a too involved.

user1172468
  • 5,306
  • 6
  • 35
  • 62
  • 1
    You haven't asked a specific question, and it's not clear what you want to do. Do you want to transform json to xml? or json to json? Please show a sample of your input, your expected output from that sample, and what version of XSLT you are using. – Sean B. Durkin Oct 23 '12 at 17:09
  • Also see http://stackoverflow.com/questions/13007280 – Sean B. Durkin Oct 23 '12 at 17:10
  • @Sean, I think I've been very clear that I want to change JSON to JSON. XSLT is an analogous technology for XML. I will add these comments to the question. – user1172468 Oct 23 '12 at 17:15

1 Answers1

1

For your tag I guess you are using JAVA,

you can take a look at http://code.google.com/p/google-gson/

My navie approach will be using the library to convert JSON to customized beans, then back to JSON

Then you can manage the mapping logic in a JAVA way.

You can also take a look at this question XSLT equivalent for JSON

Community
  • 1
  • 1
vincentlcy
  • 1,157
  • 2
  • 17
  • 19