I have the following Json, in the browser’s localstorage, I want to know if there is a way to take it and modify it with JavaScript.
The json you are seeing is modified to make it easier to understand the information, but it grows more than 22 thousand lines and exponentially due to the values of the variable called pricelist.
What I want to do is :
-
grab the json from localstorage.
-
make a method that goes through all the json and when it finds the variable “pricelist” delete the content that has “items_ids” and “items”
-
reload the json to the same key
ANNOTATIONS: -the variable lines can be empty.
-the variable pricelist can be false.
Thank you very much for your attention and your comments.
[
{
"id":"00027-008-0001",
"data":{
"lines":[
[
0,
0,
{
"product_id":23603,
"pricelist":{
"id":10,
"item_ids":[
27069,
26894
],
"items":[
{
"id":20044,
"product_tmpl_id":[
13142,
"[DNCM1LT] DESENGRASANTE NARANJA CITRUSMAX 1 LT"
]
}
]
},
"uom_id":[
1
]
}
],
[
0,
0,
{
"product_id":23666,
"pricelist":false,
"uom_id":[
1
]
}
]
],
"pos_session_id":27
}
},
{
"id":"00027-008-0002",
"data":{
"lines":[
[
0,
0,
{
"product_id":23655,
"pricelist":false,
"uom_id":[
1
]
}
]
],
"pos_session_id":27
}
},
{
"id":"00027-008-0003",
"data":{
"lines":[
],
"pos_session_id":27
}
}]