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

JSONParser parser = JSON.createParser(jsonResponse);

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?

  • 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.
    – Matt Lacey
    Feb 26, 2013 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. Feb 26, 2013 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, 2013 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. Feb 27, 2013 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. Feb 27, 2013 at 23:28

1 Answer 1


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.

  • 1
    4.3?????? :P hissssss Feb 28, 2013 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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