ts-json-simple is a TypeScript package inspired by Java's JSONObject, providing a simple and chainable API for JSON manipulation.
npm install ts-json-simpleimport { JSONObject, JSONArray } from 'ts-json-simple';Create and manipulate JSON objects in a chainable way:
const obj = new JSONObject()
.element('name', 'Megu')
.element('age', 30)
.element('skills', new JSONArray().add('TypeScript').add('Node.js'));
console.log(obj.get('name')); // "Megu"
console.log(obj.toJSON()); // {"name":"Megu","age":30,"skills":["TypeScript","Node.js"]}Create chainable JSON arrays:
const arr = new JSONArray()
.add(1)
.add(2)
.add(3)
.add(new JSONObject().element('key', 'value'));
console.log(arr.toJSON()); // [1, 2, 3, {"key":"value"}]- Fully written in TypeScript
- Inspired by Java's
JSONObject - Supports
JSONObject,JSONArray, andJSONValue - Lightweight and simple
Contributions, issues, and feature requests are welcome! Feel free to fork the repo and submit pull requests.
This project is licensed under the MIT License.