aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/format/json.lux
blob: cf3182daaaa7864f7ba1a67eddf6351a69fac1ec (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(.module:
  [library
   [lux {"-" [nat int rev list type or and]}
    ["$" documentation {"+" [documentation:]}]
    [data
     [text {"+" [\n]}
      ["%" format {"+" [format]}]]]
    [macro
     ["." template]]]]
  [\\library
   ["." /]])

(documentation: /.json
  "A simple way to produce JSON literals."
  [(json #null)]
  [(json #1)]
  [(json +123.456)]
  [(json "this is a string")]
  [(json ["this" "is" "an" "array"])]
  [(json {"this" "is"
          "an" "object"})])

(documentation: /.fields
  "Get all the fields in a JSON object."
  [(fields json)])

(documentation: /.field
  "A JSON object field getter."
  [(field key json)])

(documentation: /.has
  "A JSON object field setter."
  [(has key value json)])

(template [<name> <desc>]
  [(documentation: <name>
     (format "A JSON object field getter for " <desc> "."))]

  [/.boolean_field "booleans"]
  [/.number_field  "numbers"]
  [/.string_field  "strings"]
  [/.array_field   "arrays"]
  [/.object_field  "objects"]
  )

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            (format "Functionality for reading and writing values in the JSON format."
                    \n "For more information, please see: http://www.json.org/")
            [..json
             ..fields
             ..field
             ..has

             ..boolean_field
             ..number_field
             ..string_field
             ..array_field
             ..object_field
             
             ($.default /.Null)
             ($.default /.Boolean)
             ($.default /.Number)
             ($.default /.String)
             ($.default /.JSON)
             ($.default /.Array)
             ($.default /.Object)
             ($.default /.null?)
             ($.default /.object)
             ($.default /.equivalence)
             ($.default /.format)
             ($.default /.codec)]
            []))