diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-11-11 00:25:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-11 00:25:41 +0100 |
| commit | 88d463cabcfe2bf2b0f14e4ad34cb2741b8da686 (patch) | |
| tree | e07e6e9a4d22cce046f03b36d06af28a73fea362 /core/io/json.cpp | |
| parent | a80ec80b57f419d84d196fb46dcb5f194c880001 (diff) | |
| parent | 5288ff538d75d2ddab257a9e1e40050c9b8fa1cb (diff) | |
| download | redot-engine-88d463cabcfe2bf2b0f14e4ad34cb2741b8da686.tar.gz | |
Merge pull request #43446 from reduz/create-variant-builtin-funcs
Create Variant built-in functions.
Diffstat (limited to 'core/io/json.cpp')
| -rw-r--r-- | core/io/json.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/io/json.cpp b/core/io/json.cpp index 58bce1cf63..d61c2b8236 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -455,3 +455,35 @@ Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int & return err; } + +Error JSONParser::parse_string(const String &p_json_string) { + return JSON::parse(p_json_string, data, err_text, err_line); +} +String JSONParser::get_error_text() const { + return err_text; +} +int JSONParser::get_error_line() const { + return err_line; +} +Variant JSONParser::get_data() const { + return data; +} + +Error JSONParser::decode_data(const Variant &p_data, const String &p_indent, bool p_sort_keys) { + string = JSON::print(p_data, p_indent, p_sort_keys); + data = p_data; + return OK; +} + +String JSONParser::get_string() const { + return string; +} + +void JSONParser::_bind_methods() { + ClassDB::bind_method(D_METHOD("parse_string", "json_string"), &JSONParser::parse_string); + ClassDB::bind_method(D_METHOD("get_error_text"), &JSONParser::get_error_text); + ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParser::get_error_line); + ClassDB::bind_method(D_METHOD("get_data"), &JSONParser::get_data); + ClassDB::bind_method(D_METHOD("decode_data", "data", "indent", "sort_keys"), &JSONParser::decode_data, DEFVAL(""), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("get_string"), &JSONParser::get_string); +} |
