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

175
Visualizações
redux - async storage with associative array

I am trying to use associative arrays with redux and to store them in the async storage to retrieve on loading the app.

With redux it works very well I have real quick access to the values and can map the content very well into cards in the react native app.

Now when I store the data in async storage I have to JSON.stringify the content and JSON.parse it back on loading. Unfortunately somehow I cannot use the object the same way afterwards.

my data looks like this:

['1442-3338': { ID: '1442-3338', something: 'something', Participants: [] }, '1442-3339': { ID: '1442-3339', someting: 'something', secondArray: {} }, '1442-3340': { ID: '1442-3340', something: 'something', secondArray: {} }, '1442-3341': { ID: '1442-3341', something: 'something', secondArray: {} } ]

I can access the data via object['1442-3338'], then after storing into the storage and getting it back, which includes JSON.stringify on store and JSON.parse on load, I cannot read the data like that anymore - keys are not recognized.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found an answer already here on stackoverflow.

JSON does not allow named keys in arrays. Thus on transforming the data via JSON.stringify and JSON.parse the array lost the keys.

Had to use a "normal" object instead, which now works fine.

Link to explanation in another post

about 4 years ago · Juan Pablo Isaza Relatório
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