… | |
… | |
13 | #define F_SPACE_BEFORE 0x00000010 |
13 | #define F_SPACE_BEFORE 0x00000010 |
14 | #define F_SPACE_AFTER 0x00000020 |
14 | #define F_SPACE_AFTER 0x00000020 |
15 | #define F_ALLOW_NONREF 0x00000080 |
15 | #define F_ALLOW_NONREF 0x00000080 |
16 | #define F_SHRINK 0x00000100 |
16 | #define F_SHRINK 0x00000100 |
17 | |
17 | |
|
|
18 | // F_SKIPINVALID? |
|
|
19 | // F_EXECCODEREF? |
|
|
20 | // F_SELFCONVERT? |
|
|
21 | |
18 | #define F_PRETTY F_INDENT | F_SPACE_BEFORE | F_SPACE_AFTER |
22 | #define F_PRETTY F_INDENT | F_SPACE_BEFORE | F_SPACE_AFTER |
19 | #define F_DEFAULT 0 |
23 | #define F_DEFAULT 0 |
20 | |
24 | |
21 | #define INIT_SIZE 32 // initial scalar size to be allocated |
25 | #define INIT_SIZE 32 // initial scalar size to be allocated |
22 | #define INDENT_STEP 3 // spaces per indentation level |
26 | #define INDENT_STEP 3 // spaces per indentation level |
23 | |
27 | |
24 | #define UTF8_MAX_LEN 11 // for perls UTF-X: max. number of octets per character |
28 | #define UTF8_MAX_LEN 11 // for perls UTF-X: max. number of octets per character |
25 | #define SHORT_STRING_LEN 256 // special-case strings of up to this size |
29 | #define SHORT_STRING_LEN 512 // special-case strings of up to this size |
26 | |
30 | |
27 | #define SB do { |
31 | #define SB do { |
28 | #define SE } while (0) |
32 | #define SE } while (0) |
29 | |
33 | |
30 | static HV *json_stash; // JSON::XS:: |
34 | static HV *json_stash; // JSON::XS:: |
… | |
… | |
1037 | XPUSHs (decode_json (jsonstr, *SvJSON (self))); |
1041 | XPUSHs (decode_json (jsonstr, *SvJSON (self))); |
1038 | |
1042 | |
1039 | PROTOTYPES: ENABLE |
1043 | PROTOTYPES: ENABLE |
1040 | |
1044 | |
1041 | void to_json (SV *scalar) |
1045 | void to_json (SV *scalar) |
|
|
1046 | ALIAS: |
|
|
1047 | objToJson = 0 |
1042 | PPCODE: |
1048 | PPCODE: |
1043 | XPUSHs (encode_json (scalar, F_UTF8)); |
1049 | XPUSHs (encode_json (scalar, F_UTF8)); |
1044 | |
1050 | |
1045 | void from_json (SV *jsonstr) |
1051 | void from_json (SV *jsonstr) |
|
|
1052 | ALIAS: |
|
|
1053 | jsonToObj = 0 |
1046 | PPCODE: |
1054 | PPCODE: |
1047 | XPUSHs (decode_json (jsonstr, F_UTF8)); |
1055 | XPUSHs (decode_json (jsonstr, F_UTF8)); |
1048 | |
1056 | |