blob: a9f4c31a616ad4130b6f1cf337576929e6e5fe70 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001OPTIONAL
2EXPERIMENTAL
3SYNOPSIS
4
5 mixed json_parse(string jsonstring)
6
7DESCRIPTION
8 This efun parses the JSON object encoded as string in <jsonstr> into a
9 suitable LPC type.
10
11 Handles the following JSON types:
12 <null> -> int (0)
13 <boolean> -> int (0 or 1)
14 <int | int64> -> int
15 <double> -> float
16 <string> -> string
17 <object> -> mapping
18 <array> -> arrays
19 All other JSON types cause a runtime error.
20
21 The JSON object can nest other JSON objects.
22
23 The function is available only if the driver is compiled with Iksemel
24 support. In that case, __JSON__ is defined.
25
26LIMITATIONS
27 64 bit wide integers can only be parsed losslessly on hosts with
28 a 64 bit wide LPC int and json-c library newer than 0.90.
29
30BUGS
31 __FLOAT_MIN__ is not serialized/parsed losslessly.
32
33EXAMPLES
34 json_parse("42") -> 42
35 json_parse("42.0") -> 42.0
36 json_parse("\"hello world\\n\"") -> "hello world\n"
37 json_parse("[ 1, 2, 3, 4, 5, 6 ]") -> ({1,2,3,4,5,6})
38 json_parse("{ \"test 2\": 42.000000, \"test 1\": 42 }")
39 -> ([ "test 1": 42, "test 2": 42.0 ])
40
41HISTORY
42 Added in LDMud 3.5.0
43
44SEE ALSO
45 json_serialize(E)