I first convert txt to JSON.
const txt = JSON.stringify(`{
ErrorList: [{ 80: 'Prepared' }],
Reference: [
{
'Rule Name': 'Missing 3',
'Rule ID': 1,
'Rule Des': 'Did they provide News ?'
},
{
'Rule Name': 'Missing Zip',
'Rule ID': 2,
'Rule Des': 'Is field ?'
}
],
'Hard Violation': [
{
Violation: 0,
'Initial Servicer': 'BI',
'Total Confirmed': 0,
'Last Date': '05/16/2021'
},
{
Violation: 0,
'Initial Servicer': 'BI',
'Total Confirmed': 3,
'Last Date': '12/19/2019'
}
]
}`);
const obj = JSON.parse(txt);
console.log(obj.Reference);
Then ,I tried to get some value of the JSON ,I tried to print the "Reference" inside it ,but it returns "undefined" ,any friend can help ?
2
Answers
Thank you for all your reply ,especially from @ T.J. Crowder
The best way for me is create an object, do it directly: