简体   繁体   中英

org.json.JSONException: Unterminated string at 737 [character 738 line 1]

I'm using the org.json.JSONObject to parse some json being sent to my servlet by an iphone. I was stuck for a while by why I would be getting an error message at all. The error message was:

org.json.JSONException: Unterminated string at 737 [character 738 line 1]

After printing out what I received, I see that the string sent was indeed cut short and stopped mid-json. I can't understand why it would be cut short. There's no limit on String size is there (or at least only a memory limit surely).

Has anyone else had thins error?

Cheers

Joe

json适用于\\ n但是如果你的meesage中有任何其他特殊字符,如\\,@,&,#etc ..首先将它们转换为各自的HEX值然后发送你的消息。

If you're using the HTTP GET method to send data using query parameters, realize that there's a practical limit on the amount of data you can send that way. It's about 2000 characters (varies by server and client). You can easily exceed that when URL encoding a shorter string.

Json won't work if received string contain new line character like \\n. Try to check for it and escape the character.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM