You need to sign in to do that
Don't have an account?
Alex.Acosta
System.JSONParser is not serializable.
Now I've used this logic multiple times in the past... and they are working just fine, but this time for what ever reason I'm getting this error, 'System.JSONParser is not serializable.'
On my controller, if I just call a new instance of the class for example:
HttpResponse response; // has response from outbound call // This works just fine new JSONResponseParser(response.getBody());
This is where I get the exception on my controller...
HttpResponse response; // has response from outbound call // This throws me the error JSONResponseParser myParsedJSON = new JSONResponseParser(response.getBody());
Why is this occuring? I've done this before in the past just fine... is there just a limit to the JSON return size that causes it to not be serializable?
My sample code that's doing the parser...
public class JSONResponseParser{ private ResponseWrapper theResponse; private final JSONParser parser; public JSONResponseParser(String jsonString){ parser = JSON.createParser(jsonString); parseJSON(); } private void parseJSON(){ while (parser.nextToken() != null) { if (parser.getCurrentToken() == JSONToken.START_OBJECT) { theResponse = (ResponseWrapper)parser.readValueAs(ResponseWrapper.class); } } } }
Well if anyone else ever has this issue, it seems to resolve itself when I declare the varible to be transient.