I'm trying to display some JSON data in the browser which comes from a Python application, this data contains objects with numerical keys which order must be preserved when parsed in Javascript. Unfortunately, Javascript does not keep the order of object keys, instead sorting numerical keys in ascending order.
The purpose of this is to display events from said JSON data in a human-readable manner, so their order is important. Other questions in a similar vein suggest wrapping every object in an array but this would mean sacrificing human-readability and would force modification of the Python application, which dictionaries have no issue maintaining insertion order.
I'm aware of the Map class in Javascript which allows for a dictionary-like structure while preserving insertion order in all cases. Is there a way to make JSON.parse
output objects to Maps? Is there some third-party library I should look into?