Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

Checkout the window.localStorage

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda