android - How to parse JSON eliminating nullpointer exception -
i trying parse json creating json object result string, parse json array , looping through it.
jsonobject jsonobject = new jsonobject(json_string) json_string being result of url execution. json looks this.
{"resulto":[{"surname":null,"firstname":null,"nrc":null}]} the line jsonobject = new jsonobject brings null pointer exception. how fix this?
the exception coming because json_string null or empty better check if (!textutils.isempty(json_string)) {}before proceeding. if key has null value key_value:null jsonobject never throws exception instead set value string "null".
Comments
Post a Comment