This is my code:
JSONObject msgObject = JSONObject.fromObject(msg);
I then get a JSONException:
net.sf.json.JSONException: Unterminated string at character 239 of {...}
What am I doing wrong?
Thanks.
edit:
I create a test.txt file:
{"source":"a\n"}
the test method is this:
Scanner cin = new Scanner(new File("test1.txt"), "utf-8");
JSONObject msgObject = JSONObject.fromObject(msg);
I got this:
key:source&value:a
It seems that your msg content isn’t correct, have you tried verifying your JSON ? You can try here : http://jsonlint.com/
Edit: sorry I presumed you used a JSON String. Here is a quote from API :
Is your msg object compatible ?