Json Access, Traversal and Update

Lenses

Argonaut includes lenses as a method of accessing and updating fields within instances of the Json type, as lenses compose it's also possible to modify deeply nested fields.

Note that Json is an immutable data type modification using lenses produces new values each time.

    

Cursor

A Cursor (otherwise known as a zipper) provides the ability to move around the structure of the Json as if it were structured as a tree. Operations like left and right are available to move forwards and backwards through a JSON array. The downField method drops down into a given field of an object. Methods that modify elements such as delete or withFocus operate in relation to the current position of the cursor.

The Cursor is the most primitive zipper, but allowing access to traversal and update, but forces you to handle potential failure (using Option).

    

History Cursor and Attempt

A HCursor (History Cursor) works with an ACursor to provide a more convenient chaining of operations and also allow for more advanced tracking of operations and potential recovery from failure.

The Cursor is the most primitive zipper, but allowing access to traversal and update, but forces you to handle potential failure (using Option).