{
"d": {
"__metadata": {
"type": "typehere",
"uri": "urihere"
},
"BOLNR": "00170548",
"ToCheck_BOL_SO": {
"results": [
{
"__metadata": {
"type": "typehere",
"uri":"urihere"
},
"DOC_NUM": "0011998",
"BOLNR": "00263334",
"ToCheck_BOL_SO_DN": {
"results": [
{
"__metadata": {
"type": "typeheree",
"uri": "urihere"
},
"DOC_NUM": "0011278",
"DEL_NUM": "0805137",
"SHIP_NUM": "0011716",
"BOLNR": "26300777"
}
]
}
}
]
}
}
}
org.json' library in Java. Here’s how you can extract the desired document number from the given JSON.import org.json.JSONArray;
import org.json.JSONObject;
public class readJSON {
public static void main(String[] args) {
String input = <input here in string>;
String output="";
JSONObject jsonObject= new JSONObject(input);
output=jsonObject.getJSONObject("d")
.getJSONObject("ToCheck_BOL_SO")
.getJSONArray("results")
.getJSONObject(0)
.getJSONObject("ToCheck_BOL_SO_DN")
.getJSONArray("results")
.getJSONObject(0)
.getString("DOC_NUM");
System.out.println("Document Number: "+output);
}
}put' method as demonstrated below:JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("Name", "XYZ");
jsonObject2.put("City", "MyCity");
System.out.println(jsonObject2.toString()); {"City":"MyCity","Name":"XYZ"}org.json', makes this task achievable and efficient. With the techniques outlined in this guide, you can confidently navigate complex JSON structures and extract the data you need for your projects
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 29 | |
| 21 | |
| 19 | |
| 14 | |
| 14 | |
| 14 | |
| 13 | |
| 11 | |
| 10 | |
| 10 |