Java analysis JSONObject / JSonArray

tags: Study notes  java  

JAVA analysis jasonObject

re = {
	    "code": 0,
	    "holiday": {
	        "01-01": {
	            "holiday": true,
	            "Name": "New Year's Day",
	            "wage": 3,
	            "date": "2021-01-01",
	            "rest": 1
	        },
	        "01-02": {
	            "holiday": true,
	             "Name": "New Year's Day",
	            "wage": 2,
	            "date": "2021-01-02",
	            "rest": 1
	        },
	            "10-09": {
	            "holiday": false,
	             "Name": "The National Day is successful",
	            "after": true,
	            "wage": 1,
	             "Target": "National Day",
	            "date": "2021-10-09"
	        }
	    }
	}

JSONObject.parseObject(re.getContent()).getJSONObject("holiday");
Iterator iter = body.entrySet().iterator();
		List<HolidayEntity> dayList = new ArrayList<>();
		while(iter.hasNext()) {
			Map.Entry entry = (Entry) iter.next();
			JSONObject holidayInfo = (JSONObject) entry.getValue();
			System.out.println(holidayInfo.getString("holiday"));
		}

Java analysis jsonarray

JSONObject body = JSONObject.parseObject(result.getContent());
JSONArray	users = body.getJSONArray("userlist");
for (int i = 0; i < users.size(); i++) {
    System.out.println(  ((JSONObject)users.get(i)).getString("userid"));
}

Intelligent Recommendation

jsonarray and jsonobject

        ...

JSONOBJECT / JSONARRAY

1, import dependence 2, write test class Console output:...

jsonObject,jsonArray

JSONOBJECT, JSONARRAY Dependence` JsonObject is simple to use result ``{“name”:234,“id”:123} [{“name”:234,“id”:123}]...

JSONObject、JSONArray

The JSON used before, is a key corresponding to a value, a super simple one-to-one relationship. Now useful JSON that can be nestled in layers, taking a data so cumbersome. In fact, just like the IF e...

More Recommendation

Json Analysis JsonObject Jsonarray encountered Float unusual

1, problem background Analysis of the following JSON 2. Analysis I originally wanted to use GSON to parse, but it was always anomalous, and I thought it was a network problem because the online frame ...

Java converts jsonarray to jsonobject corresponding to the key value

Sometimes when we manipulate data, a lot of data is in jsonarry format. such as: Such a format is very typed in a tabular data type. But we have to take the name with id 1 so we have to change the var...

Insert JSONObject in the first place in JSONArray in java

Insert JSONObject in the first place in JSONArray in java I found a lot of methods on the Internet that didn't find every JSONObject data inserted in the first place of JSONArray. then, Write one by y...

JSONObject, JSONArray and java entity class conversion

JSONObject, JSONArray and java entity class conversion Under normal circumstances: Convert JSONObject to entity class: Employee employee = JSONObject.toJavaObject(param, Employee.class); Convert JSONA...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top