json.anubis
1.32 KB
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
/*
* Created by PyramIDE.
* User: フランスのトトロ
* Date: 12/12/2015
* Time: 21:48
* © Calexium
*/
read tools/basis.anubis
public define String
lib_error_to_string
(
LibraryError err
)=
if err is
{
cant_load_library then "Can't load library.",
symbol_not_found then "Symbol not found.",
external_call_failed then "External call failed.",
unknown_error then "Unknown error."
}.
public define String
to_JS_String
(
Library json_lib,
String unescaped_string
)=
if unescaped_string = "" then
"''"
else
if extension_library_call(json_lib, "to_JS_String", serialize(unescaped_string), length(unescaped_string)+30) is
{
error(err) then
println("Can't call to_JS_String");
println(" --> " + lib_error_to_string(err));
"''",
ok(ba) then to_string(ba)
}.
public define String
to_JSON_String
(
Library json_lib,
String unescaped_string
)=
if unescaped_string = "" then
"\"\""
else
if extension_library_call(json_lib, "to_JSON_String", serialize(unescaped_string), length(unescaped_string)+30) is
{
error(err) then
println("Can't call to_JSON_String");
println(" --> " + lib_error_to_string(err));
"\"\"",
ok(ba) then to_string(ba)
}.