-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_json.v
More file actions
54 lines (41 loc) · 1.29 KB
/
Copy pathphp_json.v
File metadata and controls
54 lines (41 loc) · 1.29 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
module vphp
pub struct PhpJson {}
pub fn PhpJson.encode(value ZVal) string {
return PhpJson.encode_with_flags(value, 0)
}
pub fn PhpJson.encode_with_flags(value ZVal, flags int) string {
return PhpFunction.named('json_encode').result_string(PhpValue.from_zval(value),
PhpInt.of(flags))
}
pub fn PhpJson.decode_assoc(raw string) ZVal {
mut result := PhpFunction.named('json_decode').request_owned(PhpString.of(raw),
PhpBool.of(true))
return result.take_zval()
}
pub fn PhpJson.decode_assoc_value(raw string) PhpValue {
return PhpValue.adopt_zval(PhpJson.decode_assoc(raw))
}
pub fn PhpJson.last_error_code() int {
return int(PhpFunction.named('json_last_error').result_i64())
}
pub fn PhpJson.last_error_message() string {
return PhpFunction.named('json_last_error_msg').result_string()
}
pub fn json_encode(value ZVal) string {
return PhpJson.encode(value)
}
pub fn json_encode_with_flags(value ZVal, flags int) string {
return PhpJson.encode_with_flags(value, flags)
}
pub fn json_decode_assoc(raw string) ZVal {
return PhpJson.decode_assoc(raw)
}
pub fn json_decode_assoc_value(raw string) PhpValue {
return PhpJson.decode_assoc_value(raw)
}
pub fn json_last_error_code() int {
return PhpJson.last_error_code()
}
pub fn json_last_error_message() string {
return PhpJson.last_error_message()
}