@@ -23,34 +23,39 @@ INTERFACE *Vital.Web.JSON-interface*
2323CONSTS *Vital.Web.JSON-consts*
2424
2525true *Vital.Web.JSON.true*
26- It is used to indicate 'true' in JSON string. It is represented as a
27- | Funcref | thus if you assign the value to a variable which name does not
28- start with a capital, "s:", "w:", "t:" or "b:" will raise an exception.
29- This returns 1 when you use it as a function.
26+ It is | v:true | . This is left for backward compatibility.
3027
3128false *Vital.Web.JSON.false*
32- It is used to indicate 'false' in JSON string. It is represented as a
33- | Funcref | thus if you assign the value to a variable which name does not
34- start with a capital, "s:", "w:", "t:" or "b:" will raise an exception.
35- This returns 0 when you use it as a function.
29+ It is | v:false | . This is left for backward compatibility.
3630
3731null *Vital.Web.JSON.null*
38- It is used to indicate 'null' in JSON string. It is represented as a
39- | Funcref | thus if you assign the value to a variable which name does not
40- start with a capital, "s:", "w:", "t:" or "b:" will raise an exception.
41- This returns 0 when you use it as a function.
32+ It is | v:null | . This is left for backward compatibility.
4233
4334------------------------------------------------------------------------------
4435FUNCTIONS *Vital.Web.JSON-functions*
4536
4637encode({object} [, {settings} ]) *Vital.Web.JSON.encode()*
47- Encode an object into a JSON string. Special tokens
48- (e.g. | Vital.Web.JSON.true | ) are encoded into corresponding javascript
49- tokens (e.g. 'true' ).
50- >
51- echo s:JSON.encode([s:JSON.true, s:JSON.false, s:JSON.null])
52- " => '[true, false, null]'
53- <
38+ Encode an object into a JSON string.
39+ Vim values are converted as follows:
40+ | Number | decimal number
41+ | Float | floating point number
42+ Float nan "NaN"
43+ Float inf "Infinity"
44+ Float -inf "-Infinity"
45+ | String | in double quotes (possibly null)
46+ | List | as an array (possibly null); when
47+ used recursively: []
48+ | Dict | as an object (possibly null); when
49+ used recursively: {}
50+ | Blob | as an array of the individual bytes
51+ v:false "false"
52+ v:true "true"
53+ v:none "null"
54+ v:null "null"
55+ | Funcref | not possible, error
56+ | job | not possible, error
57+ | channel | not possible, error
58+
5459 {settings} is a | Dictionary | which allows the following:
5560
5661 'indent'
@@ -94,17 +99,6 @@ decode({json}[, {settings}]) *Vital.Web.JSON.decode()*
9499 Decode a JSON string into an object that vim can treat.
95100 {settings} is a | Dictionary | which allows the following:
96101
97- 'use_token'
98- Use special tokens (e.g. | Vital.Web.JSON.true | ) to represent
99- corresponding javascript tokens (e.g. 'true' ).
100- Otherwise | v:true | , | v:false | or | v:null | are used to represent these.
101- The default value is 0.
102- >
103- echo s:JSON.decode('[true, false, null]')
104- " => [1, 0, 0]
105- echo s:JSON.decode('[true, false, null]', {'use_token': 1})
106- " => [s:JSON.true, s:JSON.false, s:JSON.null]
107- <
108102 'allow_nan'
109103 If 'allows_nan' is 0, it will raise an exception when deserializing
110104 float constants ('NaN', 'Infinity', '-Infinity').
0 commit comments