Add option to return objects as Maps to support ordered properties

Aperta
#207 6 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@jordanbtucker ci sta già lavorando.

Dal 28/8/2019.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement :+1:

I understood that the json object is designed to be unordered, and json arrays will preserve order. So if I would like to preserve the order , then I should use list instead of object, but it is not convenient if I have an OrderedDictionary in the backend.

Now I am using c# for backend, in c#, it has OrderedDictionary which will preserve the order. After I marshal the OrderedDictionary to json, the order will be lost. When I debug the code, I found the OrderedDictionary was totally fine , the only problem was JSON changed the order of the key.

After I google about how to solve the problem, I realized that I am not the only one who asked about how to keep the order of keys in json object. Most backend languages have something similar to OrderedList, when they marshal to json , they have the same problems, and all the solutions say that we should use array instead of object.

Can we have a new type of object to keep the order of the keys so that the OrderedDictionary can marshal to json with preserved order? Thanks.

Lingua principale
JavaScript
Stelle
7.2k
Fork
288
Merge medio
1g 6h
PR unite (30g)
35

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di json5/json5

Tutte le issue di json5/json5

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.