I have a Java object that contains a few String variables. When creating a json message from a Java object if one of the String values is alpha numeric, then the conversion will return back a quoted value. Else the conversion will return back a numeric value.
Example:
Class User {
String userid , password;
}
if userid = "tom" and password = "123456" then the JSON conversion returns back
"userid":"tom" and "password":123456 (numeric)
It should actually return "password":"123456"
How can I achieve this? I am using the Java parser from json.org and below is a snippet of code that converts the Java object to Json.
final JSONObject jsonObject = XML.toJSONObject(writer.toString());
res = jsonObject.toString(4);