Decode JSON string in Java with json-simple library
This is the best and easiest code: public class test { public static void main(String str[]) { String jsonString = “{\”stat\”: { \”sdr\”: \”aa:bb:cc:dd:ee:ff\”, \”rcv\”: \”aa:bb:cc:dd:ee:ff\”, \”time\”: \”UTC in millis\”, \”type\”: 1, \”subt\”: 1, \”argv\”: [{\”type\”: 1, \”val\”:\”stackoverflow\”}]}}”; JSONObject jsonObject = new JSONObject(jsonString); JSONObject newJSON = jsonObject.getJSONObject(“stat”); System.out.println(newJSON.toString()); jsonObject = new JSONObject(newJSON.toString()); System.out.println(jsonObject.getString(“rcv”)); System.out.println(jsonObject.getJSONArray(“argv”)); } … Read more