https://github.com/hildjj/cbor-edn
Parse CBOR Extended Diagnostic Notation
https://github.com/hildjj/cbor-edn
Last synced: 2 months ago
JSON representation
Parse CBOR Extended Diagnostic Notation
- Host: GitHub
- URL: https://github.com/hildjj/cbor-edn
- Owner: hildjj
- Created: 2024-08-18T20:23:40.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-02-17T22:41:54.000Z (3 months ago)
- Last Synced: 2025-03-09T11:53:18.712Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 305 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# cbor-edn
Parse CBOR Extended Diagnostic Notation as defined by
[draft-ietf-cbor-edn-literals-16](https://www.ietf.org/archive/id/draft-ietf-cbor-edn-literals-16.html)
and some CBOR working group discussions.To play with this, use the
[CBOR2 Playground](https://hildjj.github.io/cbor2/playground/index.html).## Installation
```sh
npm install cbor-edn
```## API
Full [API documentation](http://hildjj.github.io/cbor-edn/) is available.
Example:
```js
import {parseEDN} from 'cbor-edn';const bytes = parseEDN("[_2 h'010203']");
// 9a0000000143010203 in Uint8Array
```## Command Line
The CLI version of cbor-edn is useful only for diagnostic purposes. Usage:
```
edn [options] [diagnosticString]Positional:
diagnosticString The string to parse. If not given, reads from stdin.Options:
-a,--always Always add encoding indicators when re-encoding.
-n,--never Never add encoding indicators when re-encoding.
-f,--file Read file as input, if diagnosticString not given.
If "-", read stdin. May be given multiple times.
Default: "-".
-s,--startRule Entry point for the grammar. Default: "one_item"
```Example:
```sh
$ npx edn "[_2 h'010203']"
bytes: 9a0000000143010203
0x9a0000000143010203
9a 00000001 -- Array (Length: 1 item)
43 -- [0] Bytes (Length: 3)
010203js: [ Uint8Array(3) [ 1, 2, 3 ] ]
diagonstic recreated from js: "[_2 h'010203']"
```---
[](https://github.com/hildjj/cbor-edn/actions?query=workflow%3ATests)
[](https://codecov.io/gh/hildjj/cbor-edn)