aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/format/json.lux
blob: 78e8bd332890c758b5cb143f2fdc464f292b77ab (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
75
76
77
78
79
(.using
 [library
  [lux {"-" nat int rev list type or and has}
   ["$" documentation {"+" documentation:}]
   [data
    [text {"+" \n}
     ["%" format {"+" format}]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: /.json
  "A simple way to produce JSON literals."
  ["null"
   (json #null)]
  ["true"
   (json #1)]
  ["123.456"
   (json +123.456)]
  ["'this is a string'"
   (json "this is a string")]
  ["['this' 'is' 'an' 'array']"
   (json ["this" "is" "an" "array"])]
  ["{'this' 'is', 'an' 'object'}"
   (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)]
            []))