Skip to content

ts-json-simple is a TypeScript package inspired by Java's JSONObject, providing a simple and chainable API for JSON manipulation.

License

Notifications You must be signed in to change notification settings

anthony-hyo/ts-json-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-json-simple

License
npm version TypeScript

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, and JSONValue
  • 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.

About

ts-json-simple is a TypeScript package inspired by Java's JSONObject, providing a simple and chainable API for JSON manipulation.

Resources

License

Stars

Watchers

Forks