https://github.com/hazzard993/cjson-types
TypeScript definitions for cjson (Lua library)
https://github.com/hazzard993/cjson-types
json-parser lua typescript-to-lua
Last synced: about 2 months ago
JSON representation
TypeScript definitions for cjson (Lua library)
- Host: GitHub
- URL: https://github.com/hazzard993/cjson-types
- Owner: hazzard993
- Created: 2020-09-25T03:26:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-25T03:57:40.000Z (over 4 years ago)
- Last Synced: 2025-02-03T08:13:56.307Z (4 months ago)
- Topics: json-parser, lua, typescript-to-lua
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CJSON Types
TypeScript definitions for the [CJSON lua library](https://www.kyne.com.au/~mark/software/lua-cjson.php).
How to add the definitions via yarn:
```sh
yarn add hazzard993/cjson-types
```tsconfig that could help with your TypeScriptToLua setup.
This allows `import * as cjson from "cjson";`.
```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"cjson": ["./node_modules/cjson-types/cjson"]
}
}
}
``````ts
import * as cjson from "cjson";
const cjson2 = cjson.new();text = cjson.encode(value);
value = cjson.decode(text);setting = cjson.decode_invalid_numbers(setting);
setting = cjson.encode_invalid_numbers(setting);keep = cjson.encode_keep_buffer(keep);
depth = cjson.encode_max_depth(depth);
depth = cjson.decode_max_depth(depth);
[convert, ratio, safe] = cjson.encode_sparse_array(convert, ratio, safe);
```