Viewing version 0.1.0. Open the latest package page.
json_pointer
0.1.0A simple library for creating and using json-pointer (See [rfc6901:https://tools.ietf.org/html/rfc6901]).
Readme
JSON Pointer
A simple library for creating and using json-pointer (See rfc6901).
Examples
// Json Pointer Manipulation
compose(['one', 'two']); // '/one/two'
split('/one/two'); // ['one', 'two']
parent('/one/two'); // '/one'
append('/one', 'two'); // '/one/two'
isValid('/one/two'); // true
// Json Pointer Part manipulation
escape('one/two'); // 'one~1two'
unescape('one~1two'); // 'one/two'
// Get and Set values in a json object
var obj = [
{'foo': 'bar'}
]
get$('/0/foo', obj); // 'bar'
set$('/0/foo', obj, 'baz'); // [{'foo': 'baz'}]
contains('/0/foo', obj); // true
Escaping Examples
// Compose escapes parts
compose(['one/two', 'three']); // '/one~1two/three'
// Append escapes the added part
append('/one', 'two/three'); // '/one/two~1three'
// Split unescapes parts
split('/one~1two/three'); // ['one/two', 'three']
Traversal
The library is only able to traverse through objects of type Map and List. Functions will generally throw BadRouteError when attempting to traverse other types. contains will return false.
class Point {
Point(this.x, this.y);
int x;
int y;
}
contains('/x', Point(0, 0)) // false
contains('', Point(0, 0)) // true, this is ok as Point is never traversed
Changelog
0.0.0
Initial version
0.0.1
Documentation and project fomatting changes
0.0.2
Documentation updates
0.1.0
Documentation updates
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'json_pointer:0.1.0'pubspec.yaml
name: json_pointer
description: A simple library for creating and using json-pointer (See [rfc6901:https://tools.ietf.org/html/rfc6901]).
author: 'Pete <petedmc0@gmail.com>'
version: '0.1.0'
homepage: 'https://github.com/petedmc0/json_pointer'
environment:
sdk: '>=2.4.0 <3.0.0'
#dependencies:
# path: ^1.6.0
dev_dependencies:
pedantic: ^1.7.0
test: ^1.6.0
Version history
Dependencies
No direct dependencies declared.