JSDeep - deep operations on json objects
A library that contains basic operations on nested json structures.
Features
- Provides operations to manipulate json structures.
- Uses a umd format so works everywhere.
Operations
Deep freeze
Freeze object deeply.
; const obj = x: y: z: true ;const frozen = ;console;// Output: { x: { y: { z: true } } }frozenxyz = false;// Output: TypeError: Cannot assign to read only property 'z'
Deep copy
Copy object deeply.
; const obj = x: y: z: true ;const copy = ;console;// Output: { x: { y: { z: true } } }console;// Output: true
Deep merge
Deeply merge objects.
; const obj1 = x: 'x1' y: 'y1' z: 'z1' ;const obj2 = x: 'x2' y: 'y2' ;const obj3 = x: 'x3' ;const merged = ;console;// Output: { x: 'x1', y: 'y2', z: 'z3' }console;// Output: { x: 'x1', y: 'y1', z: 'z1' }
Deep get
Get a nested property from an object.
; const obj = x: y: z: 123 ;console;// Output: 123console;// Output: 123
Deep set
Set a nested property in an object.
; console;// Output: { x: { y: { z: 123 } } }console;// Output: { x: { y: { z: 123 } } }console;// Output: { a: 'a', x: { y: { z: 123 } } }
Deep exist
Deep check for a json property.
; const obj = x: y: z: 123 ;console;// Output: trueconsole;// Output: trueconsole;// Output: false
Deep equal
Deep comparison.
; const a = x: y: z: 123 ;const b = x: y: z: 123 ;const c = x: y: z: 1234 ;console;// Output: trueconsole;// Output: falseconsole;// Output: false