Sunday, 15 September 2013

Can't write JSON string in Groovy/Java -



Can't write JSON string in Groovy/Java -

so trying write next json java string getting error don't understand:

string simpleapi_messageinjson = "{ " + " \"action\": \"add\", " + " \"destinations\": { " + " \"cache\": 1, " + " \"batches\": 1 " + " }, " + " \"payload\": { " + " \"object_type\": \"profile\", " + " \"object_id\": 366334, " + " } " + " } ";

error:

com.fasterxml.jackson.core.jsonparseexception: unexpected character ('}' (code 125)): expecting double-quote start field name

you have comma:

" \"object_id\": 366334, " +

should be:

" \"object_id\": 366334 " + // /\ comma there.

the error message says:

com.fasterxml.jackson.core.jsonparseexception: unexpected character ('}' (code 125)): expecting double-quote start field name

this isn't clear, can create out it's syntax error of kind, , has line number. looking around line number, can find syntax error.

java json groovy

No comments:

Post a Comment