Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
Is it reliable to use nested JSON when using localStorage?

Really confused here. On my current project all data is stored in localStorage, and all objects/arrays have maximum one level of nesting. That results in many inconveniences and even duplicates of the same entities. I decided to refactor the data structure to something more convenient, but also more nested.

Would it be safe and reliable to JSON.stringify() / JSON.parse() back and forth such data? Some of google search results states that json does not support nested arrays, but it does support them! Or..?

what I have now:

    cars: [{id: car1, brand: 'bmw'}, {id: car2, brand: 'ford'}, {id: car3, brand: 'dodge'}]
    car1_details: {id: car1, color: 'blue', horsepower: 150, type: 'coupe'] 
    car2_details: {id: car2, color: 'red', horsepower: 180, type: 'hatchback'] 
    car3_details: {id: car3, color: 'yellow', horsepower: 200, type: 'sedan']

what I obviously want:

    cars: [ 
      {   
        id: car1,    
        brand: 'bmw',   
        details: {     
          color: 'blue',     
          horsepower: 150,     
          type: 'coupe' 
      }
    //etc 
    ]

I tested and it seems to be 100% working, but just wanted to make sure by asking you guys. Also there is this outdated post, but apparently it has been fixed since then.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda