Add option to return objects as Maps to support ordered properties

Abierto
#207 6 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@jordanbtucker ya está trabajando en esto.

Desde el 28/8/2019.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
JavaScript
Estrellas
7.2k
Forks
288
Merge medio
1 d 6 h
PR fusionados (30 d)
35

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de json5/json5

Todos los issues de json5/json5

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.