It depends on which collection you use.
Any class that implements IEnumerable / IEnumerable<T> can be serialized as a JSON array. Json.NET sequentially processes the collections, i.e. serializes the elements of the array in the order in which the collection returns them from GetEnumerator , and adds the elements to the collection in the order in which they are deserialized from the JSON file (using the Add method in the case of mutable collections and the constructor with the collection argument in the case of immutable collections).
This means that if the collection preserves the order of elements ( T[] , List<T> , Collection<T> , ReadOnlyCollection<T> , etc.), the order will be preserved during serialization and deserialization. However, if the collection does not preserve the order of elements ( HashSet<T> , etc.), the Order will be lost.
The same applies to JSON objects. For example, the order will be lost when serializing Dictionary<TKey, TValue> , because this collection does not preserve the order of elements.
source share