1

What is the elegant way to convert JSONObject to URL parameters. For example, JSONObject:

{stat: {123456: {x: 1, y: 2}, 123457: {z: 5, y: 2}}}}

this should be like:

stat[123456][x]=1&stat[123456][y]=2&stat[123457][z]=5&stat[123457][y]=2

of course with escaped symbols, and of course JSON object could be more complicated.. Maybe there already exist some mechanisms for that?

Thanks,

Alex Ivasyuv
  • 8,217
  • 17
  • 67
  • 89

2 Answers2

2

Looks like, the only way I found it to make it manually.

Alex Ivasyuv
  • 8,217
  • 17
  • 67
  • 89
1

If readability isn't a big concern, you could base64-encode the JSON string in the url, and then base64-decode inside the web server before decoding the JSON itself.

Marcelo Cantos
  • 174,413
  • 38
  • 319
  • 360
  • That looks like a custom format that is very unlikely to be supported by any general purpose library. You'll probably have to write an algorithm yourself. – Marcelo Cantos Dec 24 '10 at 09:27