@tron-format/tron
v0.1.3
Published
Token Reduced Object Notation (TRON) is a data serialization format, extended from JSON, with token efficiency features.
Maintainers
Readme
@tron-format/tron
A JavaScript library for converting data to and from the TRON (Token Reduced Object Notation) format.
See full specification for the TRON format at: https://tron-format.github.io/
Installation
npm i @tron-format/tronUsage
import { TRON } from '@tron-format/tron';
const value = { a: 1, b: 2 };
const tron = TRON.stringify(value);
console.log(tron);
// Output:
// class A: a,b
//
// A(1,2)
const parsed = TRON.parse(tron);
console.log(parsed);
// Output:
// { a: 1, b: 2 }Considerations
Using stringify with undefined
In JavaScript, calling JSON.stringify(undefined) returns undefined. However, calling TRON.stringify(undefined) returns 'null' instead. This is intentional to better align with the function's return type (string only) for TypeScript.
Other cases of stringifying undefined are handled the same way as JSON.stringify. For example:
TRON.stringify([undefined])returns'[null]'(same behavior asJSON.stringify([undefined]))TRON.stringify({ a: undefined })returns'{}'(same behavior asJSON.stringify({ a: undefined }))
Playground
Want to try out TRON with your own JSON data?
Go to https://tron-format.github.io/ and click on "Playground" in the top navigation bar.
Paste it in your data and see TRON's token efficiency compared to other data formats!
License
MIT License © 2025-PRESENT Tim Huang
