Based on the the object generated from this JSON data, how can I get only the z:row object values using javascript or jQuery? In other words, how can I filter object values from JSON?
{
"Response": {
"Request": {
"ConnectInfo": {
"USER_NAME": "",
"PASSWORD": "",
"PROJECT_ID": "",
"CONNECTION_NAME": "",
"APP_ID": "",
"CLIENT_IP": "",
"SITE": "",
"LANGUAGE": "",
"LANGUAGE_ID": "0"
},
"Method": {
"MethodID": "",
"Name": "",
"PARAMS": {
"PARAM": [{
"#id": "",
"#value": ""
},
{
"#id": "",
"#value": ""
},
{
"#id": "",
"#value": ""
},
{
"#id": "",
"#value": ""
}
]
},
"QueryControl": {
"chunk_num": "",
"rev_control": "",
"max_rows": ""
}
}
},
"MethodResponse": {
"Name": "",
"MethodID": "",
"DeResult": {
"xml": {
"#xmlns:dt": "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",
"s:Schema": {
"#id": "RowsetSchema",
"s:ElementType": {
"#content": "eltOnly",
"#name": "row",
"s:AttributeType": [{
"#name": "BACKGROUND",
"#rs:maydefer": "true",
"#rs:nullable": "true",
"#rs:number": "1",
"#rs:writeunknown": "true",
"s:datatype": {
"#dt:maxLength": "2147483647",
"#dt:type": "string",
"#rs:precision": "0"
}
],
"s:extends": {
"#types": "rs:rowbase"
},
"rs:data": {
"z:row": [{
"#BACKGROUND": "",
"#DOC.APP_FORMAT_TYPE": "NO VALUE",
"#DOC.AUTHOR": "",
"#DOC.Access_UDF": "Public",
"#DOC.BOM_DEFINING": "Yes",
"#DOC.CAGE_CODE": "CAGE_CODE1",
},
{
"#BACKGROUND": "",
"#DOC.APP_FORMAT_TYPE": "NO VALUE",
"#DOC.AUTHOR": "",
"#DOC.Access_UDF": "Public",
"#DOC.BOM_DEFINING": "Yes",
"#DOC.CAGE_CODE": "CAGE_CODE1",
},
]
},
"ResultCode": "Ok",
"ExtraResults": "",
"Messages": "",
"Trace": ""
},
"ResultCode": "Ok",
"ExtraResults": "",
"Messages": ""
}
}
"
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
"{
"Response": {
"Request": {
"ConnectInfo": {
"LANGUAGE_ID": "0"
},
"Method": {
"MethodID": "",
"Name": "",
"PARAMS": {
"PARAM": [{
"#id": "",
"#value": ""
}]
},
"QueryControl": {
"chunk_num": "",
}
}
},
"MethodResponse": {
"Name": "",
"MethodID": "",
"DeResult": {
"xml": {
"#xmlns:dt": "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882",
"s:Schema": {
"#id": "RowsetSchema",
"s:ElementType": {
"#content": "eltOnly",
"#name": "row",
"s:AttributeType": [{
"#name": "BACKGROUND",
"#rs:maydefer": "true",
"#rs:nullable": "true",
"#rs:number": "1",
"#rs:writeunknown": "true",
"s:datatype": {
"#dt:maxLength": "2147483647",
"#dt:type": "string",
"#rs:precision": "0"
}
],
"s:extends": {
"#types": "rs:rowbase"
},
"rs:data": {
"z:row": [{
"#BACKGROUND": "",
"#DOC.APP_FORMAT_TYPE": "NO VALUE",
"#DOC.AUTHOR": "",
"#DOC.Access_UDF": "Public",
"#DOC.BOM_DEFINING": "Yes",
"#DOC.CAGE_CODE": "CAGE_CODE1",
},
{
"#BACKGROUND": "",
"#DOC.APP_FORMAT_TYPE": "NO VALUE",
"#DOC.AUTHOR": "",
"#DOC.Access_UDF": "Public",
"#DOC.BOM_DEFINING": "Yes",
"#DOC.CAGE_CODE": "CAGE_CODE1",
},
]
},
"ResultCode": "Ok",
"ExtraResults": "",
"Messages": ""
}
}
Thanks for help.
I found answer like below way we can pass through each object.
var obj = data;
var json = JSON.parse(data)
json.Response.MethodResponse.DeResult.xml["rs:data"]
Related
I have a JSon like this :
[
{
"order_number": "",
"products": [
{
"line_id": "" ,
"cod_anf": "",
"static_field_2": "",
"nome_armazem": "",
"cod_armazem": "",
"gln": "",
"sku_ah": "",
"name": "",
"qty": "",
"_regular_price": "",
"_sale_price": "",
"line_total": "",
"desconto": "",
"pva": "",
"category": "",
"localidade": " ",
"codigo_ah": " ",
"Part of": ""
},
{
"line_id": "",
"cod_anf": "",
"static_field_2": "",
"nome_armazem": "",
}
],
{
"order_number": "",
"products": [
{
"line_id": 1,
"cod_anf": "",
"static_field_2": "",
I need to remove the "products" but keep it's content.
So the output should be like this:
Is it possible? I've tried and I cant make it work.
Thanks
You can use nested maps, spread operator, and flat function like below.
const json = [{
"order_number": "2",
"products": [{
"line_id": "",
"cod_anf": "",
"static_field_2": "",
"nome_armazem": "",
"cod_armazem": "",
"gln": "",
"sku_ah": "",
"name": "",
"qty": "",
"_regular_price": "",
"_sale_price": "",
"line_total": "",
"desconto": "",
"pva": "",
"category": "",
"localidade": " ",
"codigo_ah": " ",
"Part of": ""
},
{
"line_id": "",
"cod_anf": "",
"static_field_2": "",
"nome_armazem": "",
}
]
},
{
"order_number": "1",
"products": [{
"line_id": 1,
"cod_anf": "",
"static_field_2": "",
}
]
}
];
const flattened = json.map(r => [...r.products.map(q =>
({
order_number: r.order_number,
...q
})
)])
.flat(1);
console.log(flattened);
Try this, assign json to data
let obj = [];
data.forEach(order =>{
order.products.forEach(product => {
obj.push({
...product,
order_number: order.order_number
})
})
})
I have a flat array consisting of the following data
[{
"text": "",
"type": "true_false",
"ans": {
"ans_1": true,
"ans_2": false
},
"correct_ans": "",
"reason": "",
"passage": ""
},
{
"text": "",
"type": "true_false",
"ans": {
"ans_1": true,
"ans_2": false
},
"correct_ans": "",
"reason": "",
"passage": ""
}, {
"text": "",
"type": "passage",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": "",
"passage": 3
}, {
"text": "",
"type": "multichoice",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": "",
"passage": ""
}, {
"text": "",
"type": "passage",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": "",
"passage": 3
}, {
"text": "",
"type": "passage",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": "",
"passage": 5
}
]
But, I will like to group the array in the format below.
[{
"text": "",
"type": "true_false",
"ans": {
"ans_1": true,
"ans_2": false
},
"correct_ans": "",
"reason": "",
"passage": ""
},
{
"text": "",
"type": "true_false",
"ans": {
"ans_1": true,
"ans_2": false
},
"correct_ans": "",
"reason": "",
"passage": ""
}, {
"type": "passage",
"passage": 3,
"children": [{
"text": "",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": ""
}, {
"text": "",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": ""
}]
}, {
"text": "",
"type": "multichoice",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": "",
"passage": ""
}, {
"passage": 5,
"type": "passage",
"children": [{
"text": "",
"ans": {
"ans_1": "",
"ans_2": ""
},
"correct_ans": [],
"reason": ""
}]
}
]
I have searched online but; couldn't get my desired result. I also cam across this Q/A Build tree array from flat array in javascript. I tried to tweak the answer but still couldn't get my desired result.
Original json data:
{
"UniversalOne": "",
"CommonOne": ""
"Implementations": [
{
"Male": {
"Gender": "Male"
},
"Female": {
"Gender": "Female"
},
"Country": [
{
"Orientation": "Male",
"Name": ABCD
},
{
"Orientation": "Female",
"Name": EFGH
},
{
"Orientation": "Female",
"Name": IJKL
}
],
"State": [
{
"Address": "XYZ Street",
"ZipCode": "US"
}
]
}
],
"PersonalityTraits": [
{
"Type": "Positive"
},
{
"Type": "Negative"
}
],
"UniversalTwo": "",
"CommonTwo": "",
"EatingHabits": {
"Type": "Excessive"
},
"ReadingHabits": {
"Type": "Fast"
},
"FitnessHabits": {
},
"UniversalThree": "",
"CommonThree": ""
}
Expected json data:
{
"UniversalOne": "",
"CommonOne": ""
"Implementations": [
{
"Male": {
"Gender": "Male"
"Country": [
{
"Orientation": "Male",
"Name": ABCD
}
],
"State": [
{
"Address": "XYZ Street",
"ZipCode": "US"
}
]
},
"Female": {
"Gender": "Female"
"Country": [
{
"Orientation": "Female",
"Name": EFGH
},
{
"Orientation": "Female",
"Name": IJKL
}
],
"State": [
{
"Address": "XYZ Street",
"ZipCode": "US"
}
]
}
}
],
"PersonalityTraits": [
{
"Type": "Positive"
},
{
"Type": "Negative"
}
],
"UniversalTwo": "",
"CommonTwo": "",
"EatingHabits": {
"Type": "Excessive"
},
"ReadingHabits": {
"Type": "Fast"
},
"FitnessHabits": {
},
"UniversalThree": "",
"CommonThree": ""
}
Program:
//Original JSON data in question.
var Implementations = {
"UniversalOne": "",
"CommonOne": ""
"Implementations": [
{
"Male": {
"Gender": "Male"
},
"Female": {
"Gender": "Female"
},
"Country": [
{
"Orientation": "Male",
"Name": ABCD
},
{
"Orientation": "Female",
"Name": EFGH
},
{
"Orientation": "Female",
"Name": IJKL
}
],
"State": [
{
"Address": "XYZ Street",
"ZipCode": "US"
}
]
}
],
"PersonalityTraits": [
{
"Type": "Positive"
},
{
"Type": "Negative"
}
],
"UniversalTwo": "",
"CommonTwo": "",
"EatingHabits": {
"Type": "Excessive"
},
"ReadingHabits": {
"Type": "Fast"
},
"FitnessHabits": {
},
"UniversalThree": "",
"CommonThree": ""
}
// Program that make the conversion
var finalResult = [];
for (var i=0; i<Implementations.Implementations.length; i++) {
var currentImplementation = Implementations.Implementations[i];
var targetObj = {
"Male": {
"Gender": "Male",
"Country": [],
"State": currentImplementation.State
},
"Female": {
"Gender": "Female",
"Country": [],
"State": currentImplementation.State
}
};
for (var j=0; j<currentImplementation.Country.length; j++) {
var currentCountry = currentImplementation.Country[j];
if (currentCountry.Orientation === 'Male') {
targetObj.Male.Country.push(currentCountry);
} else if (currentCountry.Orientation === 'Female') {
targetObj.Female.Country.push(currentCountry);
}
}
finalResult.push(targetObj);
}
console.log(JSON.stringify(finalResult));
How do I add the objects like Personality Traits, Eating Habits, Reading Habits, Fitness Habits and attributes like Universal and common outside of the Implementations object as shown in the expected json data?
The easiest way would be using Object.assign to merge the attributes.
//The Original Data
const Implementations = {
"Implementations": [
{
//Ignore
}
]
}
//The Attributes needed
const attributes = {
"UniversalOne": "",
"CommonOne": "",
"PersonalityTraits": [
{
"Type": "Positive"
},
{
"Type": "Negative"
}
],
"UniversalTwo": "",
"CommonTwo": "",
"EatingHabits": {
"Type": "Excessive"
},
"ReadingHabits": {
"Type": "Fast"
},
"FitnessHabits": {
},
"UniversalThree": "",
"CommonThree": ""
}
const newData = Object.assign({}, Implementations, attributes);
console.dir(newData);
OR just add the data inside.
const Implementations = {
"Implementations": [
{
//Ignore
}
]
}
const newData = {
"UniversalOne": "",
"CommonOne": "",
"PersonalityTraits": [
{
"Type": "Positive"
},
{
"Type": "Negative"
}
],
"UniversalTwo": "",
"CommonTwo": "",
"EatingHabits": {
"Type": "Excessive"
},
"ReadingHabits": {
"Type": "Fast"
},
"FitnessHabits": {
},
"UniversalThree": "",
"CommonThree": ""
}
newData.Implementations = Implementations.Implementations;
console.dir(newData);
I want to flatten my json nested array object to flat array
Both key and value pair should be dynamic as per the user input array
I tried to code myself but I am not much familiar with JavaScript function to do concat, push or other funtions.
Input:
{
"ReportID": "ProfitAndLoss",
"ReportName": "Profit and Loss",
"ReportType": 7,
"ReportTitles": [
"Profit & Loss",
"Clearlight Saunas Australia Pty Ltd",
"1 May 2017 to 31 May 2017"
],
"ReportDate": "17 May 2017",
"UpdatedDateUTC": "2017-05-17T05:52:23.414Z",
"Attributes": null,
"Fields": [],
"Rows": [
{
"RowType": "Header",
"Cells": [
{
"Value": "",
"Attributes": null
},
{
"Value": "31 May 17",
"Attributes": null
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Section",
"Cells": null,
"Title": "Income",
"Rows": [
{
"RowType": "Row",
"Cells": [
{
"Value": "Curve Dome Sauna",
"Attributes": [
{
"Value": "a76bacdc-a411-4924-9860-7c8b1bf36e5b",
"Id": "account"
}
]
},
{
"Value": "6725.46",
"Attributes": [
{
"Value": "a76bacdc-a411-4924-9860-7c8b1bf36e5b",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Essential Sauna Sales",
"Attributes": [
{
"Value": "b2544842-1e51-4c08-80bc-7077f01a8657",
"Id": "account"
}
]
},
{
"Value": "21359.09",
"Attributes": [
{
"Value": "b2544842-1e51-4c08-80bc-7077f01a8657",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Premier Sauna Sales",
"Attributes": [
{
"Value": "7f5bb82f-f488-441e-b578-c3e6d16829f0",
"Id": "account"
}
]
},
{
"Value": "19088.18",
"Attributes": [
{
"Value": "7f5bb82f-f488-441e-b578-c3e6d16829f0",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Revenue - Installation ",
"Attributes": [
{
"Value": "e4985303-4ce7-4162-9ed3-e9a7799b5584",
"Id": "account"
}
]
},
{
"Value": "636.36",
"Attributes": [
{
"Value": "e4985303-4ce7-4162-9ed3-e9a7799b5584",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Sanctuary sauna sale",
"Attributes": [
{
"Value": "90bda37d-e484-494c-8ad5-dd012f6acb56",
"Id": "account"
}
]
},
{
"Value": "26244.55",
"Attributes": [
{
"Value": "90bda37d-e484-494c-8ad5-dd012f6acb56",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Sauna cover sale",
"Attributes": [
{
"Value": "5a1aa34f-9acb-4154-8d4c-bb7e56a16cc8",
"Id": "account"
}
]
},
{
"Value": "727.27",
"Attributes": [
{
"Value": "5a1aa34f-9acb-4154-8d4c-bb7e56a16cc8",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "SummaryRow",
"Cells": [
{
"Value": "Total Income",
"Attributes": null
},
{
"Value": "74780.91",
"Attributes": null
}
],
"Title": null,
"Rows": null
}
]
},
{
"RowType": "Section",
"Cells": null,
"Title": "",
"Rows": [
{
"RowType": "Row",
"Cells": [
{
"Value": "Gross Profit",
"Attributes": null
},
{
"Value": "74780.91",
"Attributes": null
}
],
"Title": null,
"Rows": null
}
]
},
{
"RowType": "Section",
"Cells": null,
"Title": "Plus Other Income",
"Rows": [
{
"RowType": "Row",
"Cells": [
{
"Value": "Sauna Sale to Clearlight NZ Ltd",
"Attributes": [
{
"Value": "12eca2ea-00ff-4f1a-9187-bd3faaf15eae",
"Id": "account"
}
]
},
{
"Value": "1309.09",
"Attributes": [
{
"Value": "12eca2ea-00ff-4f1a-9187-bd3faaf15eae",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "SummaryRow",
"Cells": [
{
"Value": "Total Other Income",
"Attributes": null
},
{
"Value": "1309.09",
"Attributes": null
}
],
"Title": null,
"Rows": null
}
]
},
{
"RowType": "Section",
"Cells": null,
"Title": "Less Operating Expenses",
"Rows": [
{
"RowType": "Row",
"Cells": [
{
"Value": "Bank Fees",
"Attributes": [
{
"Value": "1ee9c97a-5707-4289-9d40-fa25d2f087d3",
"Id": "account"
}
]
},
{
"Value": "503.54",
"Attributes": [
{
"Value": "1ee9c97a-5707-4289-9d40-fa25d2f087d3",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "Row",
"Cells": [
{
"Value": "Sauna Storage",
"Attributes": [
{
"Value": "f3813ca9-9a0f-4c31-8afb-a1f9af61ca9a",
"Id": "account"
}
]
},
{
"Value": "670.00",
"Attributes": [
{
"Value": "f3813ca9-9a0f-4c31-8afb-a1f9af61ca9a",
"Id": "account"
}
]
}
],
"Title": null,
"Rows": null
},
{
"RowType": "SummaryRow",
"Cells": [
{
"Value": "Total Operating Expenses",
"Attributes": null
},
{
"Value": "1173.54",
"Attributes": null
}
],
"Title": null,
"Rows": null
}
]
},
{
"RowType": "Section",
"Cells": null,
"Title": "",
"Rows": [
{
"RowType": "Row",
"Cells": [
{
"Value": "Net Profit",
"Attributes": null
},
{
"Value": "74916.46",
"Attributes": null
}
],
"Title": null,
"Rows": null
}
]
}
]
}
This is the desired output i want:
[
{
"ReportID": "ProfitAndLoss",
"ReportName": "Profit and Loss",
"ReportType": "7",
"ReportTitles": "Profit & Loss",
"ReportDate": "17 May 2017",
"UpdatedDateUTC": "2017-05-17T05:52:23.414Z",
"Attributes": null,
"Rows__RowType": "Header",
"Rows__Cells": "",
"Rows__Cells____Value": "",
"Rows__Cells____Attributes": null,
"Rows__Title": null,
"Rows__Rows____RowType": "",
"Rows__Rows____Cells__Value": "",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "",
"Rows__Rows____Cells__Attributes____Id": "",
"Rows__Rows____Title": "",
"Rows__Rows____Rows": "",
"Rows__Rows": null
},
{
"ReportID": "",
"ReportName": "",
"ReportType": "",
"ReportTitles": "Clearlight Saunas Australia Pty Ltd",
"ReportDate": "",
"UpdatedDateUTC": "",
"Attributes": "",
"Rows__RowType": "",
"Rows__Cells": "",
"Rows__Cells____Value": "31 May 17",
"Rows__Cells____Attributes": null,
"Rows__Title": "",
"Rows__Rows____RowType": "",
"Rows__Rows____Cells__Value": "",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "",
"Rows__Rows____Cells__Attributes____Id": "",
"Rows__Rows____Title": "",
"Rows__Rows____Rows": "",
"Rows__Rows": ""
},
{
"ReportID": "",
"ReportName": "",
"ReportType": "",
"ReportTitles": "1 May 2017 to 31 May 2017",
"ReportDate": "",
"UpdatedDateUTC": "",
"Attributes": "",
"Rows__RowType": "Section",
"Rows__Cells": null,
"Rows__Cells____Value": "",
"Rows__Cells____Attributes": "",
"Rows__Title": "Income",
"Rows__Rows____RowType": "Row",
"Rows__Rows____Cells__Value": "Curve Dome Sauna",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "a76bacdc-a411-4924-9860-7c8b1bf36e5b",
"Rows__Rows____Cells__Attributes____Id": "account",
"Rows__Rows____Title": null,
"Rows__Rows____Rows": null,
"Rows__Rows": ""
},
{
"ReportID": "",
"ReportName": "",
"ReportType": "",
"ReportTitles": "",
"ReportDate": "",
"UpdatedDateUTC": "",
"Attributes": "",
"Rows__RowType": "",
"Rows__Cells": "",
"Rows__Cells____Value": "",
"Rows__Cells____Attributes": "",
"Rows__Title": "",
"Rows__Rows____RowType": "",
"Rows__Rows____Cells__Value": "6725.46",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "a76bacdc-a411-4924-9860-7c8b1bf36e5b",
"Rows__Rows____Cells__Attributes____Id": "account",
"Rows__Rows____Title": "",
"Rows__Rows____Rows": "",
"Rows__Rows": ""
},
{
"ReportID": "",
"ReportName": "",
"ReportType": "",
"ReportTitles": "",
"ReportDate": "",
"UpdatedDateUTC": "",
"Attributes": "",
"Rows__RowType": "",
"Rows__Cells": "",
"Rows__Cells____Value": "",
"Rows__Cells____Attributes": "",
"Rows__Title": "",
"Rows__Rows____RowType": "Row",
"Rows__Rows____Cells__Value": "Essential Sauna Sales",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "b2544842-1e51-4c08-80bc-7077f01a8657",
"Rows__Rows____Cells__Attributes____Id": "account",
"Rows__Rows____Title": null,
"Rows__Rows____Rows": null,
"Rows__Rows": ""
},
{
"ReportID": "",
"ReportName": "",
"ReportType": "",
"ReportTitles": "",
"ReportDate": "",
"UpdatedDateUTC": "",
"Attributes": "",
"Rows__RowType": "",
"Rows__Cells": "",
"Rows__Cells____Value": "",
"Rows__Cells____Attributes": "",
"Rows__Title": "",
"Rows__Rows____RowType": "",
"Rows__Rows____Cells__Value": "21359.09",
"Rows__Rows____Cells__Attributes": "",
"Rows__Rows____Cells__Attributes____Value": "b2544842-1e51-4c08-80bc-7077f01a8657",
"Rows__Rows____Cells__Attributes____Id": "account",
"Rows__Rows____Title": "",
"Rows__Rows____Rows": "",
"Rows__Rows": ""
}]
You can store this json in a variable and make use of something like
JSON.parse(variable_name);
After this it's in the form of an array and you can easily loop through it
Hope this helps!
I use jQuery get a JSON string from a API. I want to display it and change some field and PUT back to the API. But it seems to hard to gather information from input box and put it into right field.
Here is the json structure:
{
"economicStatus": "",
"title1": "",
"migrantEducation": "",
"disability": {
"status": "",
"section504Status": "",
"primaryDisability": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"awaitingInitialIDEAEvaluation": ""
},
"giftedTalented": "",
"firstNationalEnrollment": "",
"alertMessageList": [
{
"message": "object",
"messageType": ""
}
],
"medicalAlertMessageList": [
{
"message": "",
"severity": ""
}
],
"projectedGraduationYear": "",
"onTimeGraduationYear": "",
"graduationDate": "",
"economicDisadvantage": "",
"otherIdList": [
{
"idValue": "object",
"idType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
}
],
"name": {
"nameRole": "",
"actualNameOfRecord": {
"prefix": "",
"familyNameFirst": "",
"preferredFamilyNameFirst": "",
"givenName": "",
"middleName": "",
"familyName": "",
"preferredFamilyName": "",
"preferredGivenName": "",
"fullName": "",
"sortName": "",
"suffix": ""
}
},
"phoneNumberList": [
{
"number": "",
"extension": "",
"phoneNumberType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"listedStatus": ""
}
],
"emailList": [
{
"emailAddress": "",
"emailType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
}
],
"localId": {
"idValue": "object",
"idType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
},
"externalId": {
"idValue": "object",
"idType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
},
"addressRefIdList": [
{
"value": "",
"addressRole": ""
}
],
"otherNameList": [
{
"nameRole": "",
"otherName": {
"prefix": "",
"familyNameFirst": "",
"preferredFamilyNameFirst": "",
"givenName": "",
"middleName": "",
"familyName": "",
"preferredFamilyName": "",
"preferredGivenName": "",
"fullName": "",
"sortName": "",
"suffix": ""
}
}
],
"demographics": {
"birthDateVerification": "",
"sexus": "",
"birthDate": "",
"subregionOfBirth": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"stateProvinceOfBirth": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"placeOfBirth": "",
"countryOfBirth": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"countryArrivalDate": "",
"citizenshipStatus": "",
"languageProficiency": "",
"dwellingArrangement": "",
"maritalStatus": "",
"ethnicityList": [
{
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
],
"languageList": [
{
"languageCode": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"languageType": "",
"dialect": ""
}
],
"countryOfResidency": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
},
"countryOfCitizenshipList": [
{
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
]
},
"electronicIdList": [
{
"idValue": "object",
"idType": {
"code": "",
"codesetName": "",
"item": "object",
"otherCodeList": [
{
"value": "",
"codesetName": ""
}
]
}
}
],
"refId": ""
}
And here is a sample data I get back from API, with some field are null:
{
"disability": null,
"economicStatus": null,
"migrantEducation": null,
"title1": null,
"alertMessageList": null,
"medicalAlertMessageList": null,
"projectedGraduationYear": null,
"onTimeGraduationYear": null,
"graduationDate": null,
"giftedTalented": null,
"economicDisadvantage": null,
"firstNationalEnrollment": null,
"otherIdList": [
{
"idType": {
"code": "AuthenticationUsername",
"item": null,
"otherCodeList": null,
"codesetName": "HMH.OtherId"
},
"idValue": "ChK#username-60ty"
},
{
"idType": {
"code": "HMOF UserName",
"item": null,
"otherCodeList": null,
"codesetName": "HMH.OtherId"
},
"idValue": "ChK#username-60ty.arda.stu"
},
{
"idType": {
"code": "Role",
"item": null,
"otherCodeList": null,
"codesetName": "HMH.OtherId"
},
"idValue": "learner"
}
],
"addressRefIdList": null,
"name": null,
"localId": {
"idType": {
"code": "LASID",
"item": null,
"otherCodeList": null,
"codesetName": "HMH.LocalId"
},
"idValue": "79800003270ABCKrtg12"
},
"externalId": {
"idType": {
"code": "SASID",
"item": null,
"otherCodeList": null,
"codesetName": "HMH.ExternalId"
},
"idValue": "NULL"
},
"electronicIdList": null,
"otherNameList": null,
"demographics": null,
"phoneNumberList": null,
"emailList": null,
"refId": "3329962f-18ab-415f-addb-132cbe613d68"
}
Is there a simple way to change the fields in a page using input box? I try to create as many input boxes as needed and name them and associate them with corresponding JSON field... But it seems to tedious and can not update array dynamically.