0.0.2 • Published 10 months ago

@rtprog/json-string v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

json-string

Library for passing JSON structures in plain string.

This library was created for the purpose of creating JSON Converter for AsciiDoctorJ. By default, AsciiDoctorJ works with plain text (string) and does not support other types are not supported by converters.

The idea is to espace JSON string with non-printable characters (start: \0, end:\u0001) and then parse it back to JSON object.

This library provides two methods:

  • parse,
  • stringify.

Installation

npm install @rtprog/json-string

Usage

const { parse, stringify } = require('json-string');

const str='Plain string' + stringify({a: 1, b: '2', c: [3, 4, 5]}) + '. More text';

console.log(str);
// Plain string{"a":1,"b":"2","c":[3,4,5]}. More text
console.log(parse(str));
// [ 'Plain string', { a: 1, b: '2', c: [ 3, 4, 5 ] }, '. More text' ]
0.0.2

10 months ago

0.0.1

10 months ago