Answers for "json data syntax"

3

JSON Syntax

{
    "naming": "Umair Ali",
    "fee": 4567.8,
    "rollNo": 33,
    "fruits": [
        "banana",
        "apple",
        "orange"
    ],
    "nesting": {
        "school": "Paras",
        "class": 9,
        "myObj": [
            "english",
            "history",
            "science",
            65.4,
            {
                "boolean": true
            },
            "InternetKiDunya.Com"
        ]
    }
}
Posted by: Guest on July-07-2021
3

json data

[{"_id":"60beb338abe3dd4300d844b8","email":"[email protected]","typeVaccine":"Moderna","status":"Yes","__v":0},{"_id":"60bf716b145de95f1c84fb2f","email":"[email protected]","typeVaccine":"Asternzcana","status":"No","__v":0},{"_id":"60bf7196145de95f1c84fb31","email":"[email protected]","typeVaccine":"Phizer","status":"Yes","__v":0},{"_id":"60bf758f145de95f1c84fb32","email":"[email protected]","typeVaccine":"none","status":"No","__v":0},{"_id":"60bf7cda145de95f1c84fb33","email":"[email protected]","typeVaccine":"Moderna","status":"Yes","__v":0}]
Posted by: Guest on June-08-2021
3

json object

var myObj, x;
myObj = {"name":"John", "age":30, "car":null};
x = myObj.name;
document.getElementById("demo").innerHTML = x;
Posted by: Guest on April-16-2020
0

json syntax

ArrayList<Countries> listCountries = new ArrayList<>();//country
        ArrayList<Detail> listDetails = new ArrayList<>();//listDetail
        ArrayList<Detail> listSub =  new ArrayList<>();//List Sub

        Countries countries = new Countries();
        countries.setId("1");
        countries.setName("Sim");
        countries.setGender("M");
        countries.setCountry("khompong Chhnang");
        countries.setPostalCode("225566");
        //Add Countries object to ArrayList
        listCountries.add(countries);

        Detail detail =  new Detail();
        detail.setPhone("09659694146");
        detail.setAddress("11H");
        //Add Detail object to ArrayList
        listDetails.add(detail);

        Detail detail1 =  new Detail();
        detail1.setPhone("2222");
        detail1.setAddress("tttt2");
        listSub.add(detail1);

        JSONObject jsonObject_sub = new JSONObject();
        JSONArray jsonArray_sub = new JSONArray();
        for (int i = 0; i < listSub.size(); i++){
            try {
                jsonObject_sub.put("Phone",listSub.get(i).getPhone());
                jsonObject_sub.put("Address",listSub.get(i).getAddress());
                jsonArray_sub.put(jsonObject_sub);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        JSONObject jb = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i<listDetails.size(); i++){
            //convert to JSONObject
            try {
                jb.put("Address",listDetails.get(i).getAddress());
                jb.put("Phone",listDetails.get(i).getPhone());
                jb.put("sub_detail",jsonArray_sub);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        //convert JSONObject to JSONArray
        for (int i = 0; i < 3; i++){
            jsonArray.put(jb);
        }


        JSONObject jsonObject = new JSONObject();
        for (int i=0; i<listCountries.size(); i++){
            try {
                //convert to JSONObject
                jsonObject.put("id",listCountries.get(i).getId());
                jsonObject.put("name",listCountries.get(i).getName());
                jsonObject.put("gender",listCountries.get(i).getGender());
                //put JSONArray into JSONObject
                jsonObject.put("detail",jsonArray);
                jsonObject.put("country",listCountries.get(i).getCountry());
                jsonObject.put("postal_code",listCountries.get(i).getPostalCode());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            Log.d(">>>", "jsonObject: "+jsonObject);
        }


================Output===========================================================
  {"id":"1","name":"Sim","gender":"M","detail":[{"Address":"11H","Phone":"09659694146","sub_detail":[{"Phone":"2222","Address":"tttt2"}]},{"Address":"11H","Phone":"09659694146","sub_detail":[{"Phone":"2222","Address":"tttt2"}]},{"Address":"11H","Phone":"09659694146","sub_detail":[{"Phone":"2222","Address":"tttt2"}]}],"country":"khompong Chhnang","postal_code":"225566"}
Posted by: Guest on December-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language