ts-json-simple
v1.0.2
Published
TypeScript package inspired by Java's JSONObject, providing a chainable API for JSON manipulation.
Downloads
9
Maintainers
Readme
ts-json-simple
ts-json-simple is a TypeScript package inspired by Java's JSONObject, providing a simple and chainable API for JSON manipulation.
⚙️ Installation
npm install ts-json-simple🚀 Usage
Import
import { JSONObject, JSONArray } from 'ts-json-simple';JSONObject
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"]}JSONArray
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"}]📦 Features
- Fully written in TypeScript
- Inspired by Java's
JSONObject - Supports
JSONObject,JSONArray, andJSONValue - Lightweight and simple
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to fork the repo and submit pull requests.
📜 License
This project is licensed under the MIT License.
