The error message I got is:
org.json.JSONException: Unterminated object at character 14 of {address: yo test}
I think that I should escape the string, but in vain after trying all the method on StackOverflow.
Here is my code, thanks a lot for any help:
// src/Activity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try{
String str = getString(R.string.data);
JSONObject jsonObj = new JSONObject(str);
}
catch(Exception e){
Log.d("iLoveDrinkActivity", e.toString());
// org.json.JSONException: Unterminated object at character 14 of {address: yo test}
}
}
And...
// res/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="data">{"address": "yo test"}</string>
</resources>
If the "address" is something else like "test" or "yo" or "123", everything works fine. Thanks again!!