Groovy JsonSlurper Issue involving commas in JSON -


i have json coming controller, call params.formdata, looks this:

'{"year":"2014","resource":["smith, john","foo, bar"]}' 

my code parse it:

.... def slurper = new jsonslurper() def data = slurper.parsetext(params.formdata) ... 

data looks like:

[resource:["smith", "john", "foo", "bar"], year:"2014"] 

notice there 2 json entries, , parser made array of 4 entries. want this:

[resource:["smith, john", "foo, bar"], year:"2014"] 

does know how handle situation?

i don't think does.

assert data.resource.size() == 2 

should prove me right ;-)

my guess output of printing data:

[resource:[smith, john, foo, bar], year:2014] 

confused things. looks 4, it's 2


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -