I get a weird problem trying to parse simple json using google simple-json.
Here is my code that does not work:
String s = args[0].toString();
JSONObject json = (JSONObject)new JSONParser().parse(s);
When I complete, it will give me an exception java.lang.String cannot be cast to org.json.simple.JSONObject
But when I hard code json directly, as below its working capacity. Wat could be the reason?
JSONObject json = (JSONObject)new JSONParser().parse("{\"application\":\"admin\",\"keytype\":\"PRODUCTION\",\"callbackUrl\":\"qwerewqr;ewqrwerq;qwerqwerq\",\"authorizedDomains\":\"ALL\",\"validityTime\":\"3600000\",\"retryAfterFailure\":true}");
UPDATE
When I type s, it will give me the following result:
"{\"application\":\"admin\",\"keytype\":\"PRODUCTION\",\"callbackUrl\":\"qwerewqr;ewqrwerq;qwerqwerq\",\"authorizedDomains\":\"ALL\",\"validityTime\":\"3600000\",\"retryAfterFailure\":true}"
source
share