JSON Lens
Create Lenses from JSON Pointer.
Starting with this JSON:
var market = foods: fruits: 'apples' 'oranges' veggies: 'peas' 'carrots' ;
We can create lenses using JSON pointers.
var firstFruit = ;var secondVeggie = ;
And use them to get values from our JSON object
t;t;
Or set values within it
firstFruit;t; secondVeggie;t;
Or set by modifying existing values
{ return v+'!';} firstFruit;t; secondVeggie;t;
Retaining the structure of our JSON all along
var result = foods: fruits: 'bananas!' 'oranges' veggies: 'peas' 'onions!' ;t;
Credits
Pointer get/set code modified from JSON Pointer and lens implementation from Ramda. Both projects are licensed under MIT.