Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm getting the following error trying to parse a string with some strange characters:

JSONParser parser = JSON.createParser(jsonResponse);
....
parser.getText();

System.JSONException: Unexpected end-of-input: was expecting closing quote for a string value at input location

I believe the value in question contains characters like ä, which are supposedly chinese characters in a database. Are these characters supported in Salesforce? If not, is my only real option throwing a try catch around all my "getText()" calls to just set the value to empty string or something?

share|improve this question
    
I'd suggest posting the full JSON response so people can help you more effectively. I wouldn't expect other characters to cause an issue with strings, it sounds like genuinely malformed JSON. –  LaceySnr Feb 26 '13 at 22:32
1  
Unfortunately it is production level data -- it just happens to work normally and when I find errors I can look back at the source and find a matching strange character in the column that the debug log refers to as the failure. –  Michael Welburn Feb 26 '13 at 23:06
    
Without seeing an actual failing JSON response, it's pretty hard to give you an answer. Everything else in Salesforce can handle unicode characters, so I'd be reasonably surprised if it was just the characters causing it to break –  James Hill Feb 26 '13 at 23:47
2  
I'm hoping to get an explicit JSON to take a look at tomorrow - when I manually try to pass over these characters (or update the database to test) it works fine, so to @LaceySnr's point it might be some strange character code that isn't escaped or creates some sort of malformed JSON. –  Michael Welburn Feb 27 '13 at 2:05
1  
After doing more debugging, it is actually unescaped ampersands (&) inside the JSON values that is giving that error. I'm leveraging PHP 4.3 to generate this, so I unfortunately can't use json_encode. –  Michael Welburn Feb 27 '13 at 23:28
show 1 more comment

1 Answer

up vote 2 down vote accepted

This wasn't a Salesforce issue, so much as it was an issue with the input. I was using PHP to json_encode in a PHP4.3 environment with JSONWrapper, and the ampersands in the data were not being escaped. Salesforce was trying to parse JSON values with ampersands and treating it as a new parameter. Once I added urlencode($data) within my PHP file prior to sending it to Salesforce it was resolved.

share|improve this answer
    
4.3?????? :P hissssss –  user320 Feb 28 '13 at 0:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.