Hey there, I receive my JSON data as an object in the following format:
{
"id": "001724",
"select": false,
"class": "product",
"Names": [
"A",
"B",
"C"
],
"available": true,
"description": "selected product",
}
I am looking to organize and sort this JSON data using Underscore.js in my JavaScript file. My goal is to create new objects based on the names within the existing object and add a "name" attribute to each one of them.
[{
A:[
0:{
"name":"A"
"id": "001724",
"select": false,
"class": "product",
"available": true,
"description": "selected product"
}
]
B:[
0:{
"name":"B"
"id": "001724",
"select": false,
"class": "product",
"available": true,
"description": "selected product"
}
]
C:[
0:{
"name":"C"
"id": "001724",
"select": false,
"class": "product",
"available": true,
"description": "selected product"
}
]
default:[
0:{
"name":"B"
"id": "001724",
"select": false,
"class": "product",
"available": true,
"description": "selected product"
}
]
}]
In addition, the default array will contain the same data as the 'B' array.
I am currently working on accomplishing this task using underscore.js library.