Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
JavaScript - Modify localstorage json

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 :

  1. grab the json from localstorage.

  2. 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"

  3. 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
    }
}]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can do it like the following:

let obj = JSON.parse(localStorage.get("item"));
obj.key = "value";
localStorage.set("item", JSON.stringify(obj));
about 4 years ago · Juan Pablo Isaza Report

0

Checkout the window.localStorage

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!