-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
51 lines (49 loc) · 1.46 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Tideland Go Dynamic JSON
//
// Copyright (C) 2019-2023 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
// Package dynaj provides a simple dynamic handling of JSON documents.
// Values can be retrieved, set and added by paths like "foo/bar/3".
// Methods provide typesafe access to the values as well as flat and
// deep processing.
//
// doc, err := dynaj.Unmarshal(myDoc)
// if err != nil {
// ...
// }
// name := doc.ValueAt("/name").AsString("")
// street := doc.ValueAt("/address/street").AsString("unknown")
//
// Another way is to create an empty document with
//
// doc := dynaj.NewDocument()
//
// Here as well as in parsed documents values can be set with
//
// err := doc.SetValueAt("/a/b/3/c", 4711)
//
// Additionally values of the document can be processed recursively
// using
//
// err := doc.Root().Process(func(node *dynaj.Node) error {
// ...
// })
//
// or from deeper nodes with doc.ValueAt("/a/b/3").Process(...).
// Additionally flat processing is possible with
//
// err := doc.ValueAt("/x/y/z").Range(func(node *dynaj.Node) error {
// ...
// })
//
// To retrieve the differences between two documents the function
// dynaj.Compare() can be used:
//
// diff, err := dynaj.Compare(firstDoc, secondDoc)
//
// privides a dynaj.Diff instance which helps to compare individual
// paths of the two document.
package dynaj // import "tideland.dev/go/text/dynaj"
// EOF