New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simple-json-order

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-json-order

A lightweight JavaScript utility to preserve the insertion order of top-level keys in JSON objects — ideal for config files, logs, or any use case where key order matters.

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Simple JSON Order

This is a lightweight JavaScript utility that allows you to preserve the insertion order of top-level keys when working with JSON.

JavaScript objects do not guarantee key order when the keys are numeric or mixed. This can lead to problems in cases where key order matters — such as configuration files, logs, diffs, or structured data that must be rendered predictably.

import { JSONOrder } from "simple-json-order";

const jsonOrdered = new JSONOrder();

//This adds values
jsonOrdered.add("a", "value a");
jsonOrdered.add("5", "value 5");
jsonOrdered.add("20", "value 10");

//You can delete values using delete
//The values keys will be stored as string always
jsonOrdered.add(5);

// To convert to string run stringify()
jsonOrdered.stringify();

// if you want to load a sorted json use parse()
jsonOrdered.parse('{"20": "value 20", "5": "value 5", "100": "value 100"}');

Keywords

json

FAQs

Package last updated on 22 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts