summaryrefslogtreecommitdiff
path: root/core/variant
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-19 21:45:34 +0200
committerGitHub <noreply@github.com>2021-06-19 21:45:34 +0200
commitd88be9b70cfecb0ec525216c1bb6267c9d1aa17d (patch)
treef0493f77faaea415faab110fe00cb71d27ebea0e /core/variant
parentd7a42a44be107d048447dcaeba7c508402096d90 (diff)
parent2bafcd3422bea8baf2282f5de87538a59f0bb254 (diff)
Merge pull request #44806 from madmiraal/consolidate_json
Consolidate JSON, JSONParseResults and JSONParser into JSON
Diffstat (limited to 'core/variant')
-rw-r--r--core/variant/variant.cpp6
-rw-r--r--core/variant/variant.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 4e45862fd3..badb5ba103 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -32,6 +32,7 @@
#include "core/core_string_names.h"
#include "core/debugger/engine_debugger.h"
+#include "core/io/json.h"
#include "core/io/marshalls.h"
#include "core/io/resource.h"
#include "core/math/math_funcs.h"
@@ -1838,6 +1839,11 @@ String Variant::stringify(List<const void *> &stack) const {
return "";
}
+String Variant::to_json_string() const {
+ JSON json;
+ return json.stringify(*this);
+}
+
Variant::operator Vector2() const {
if (type == VECTOR2) {
return *reinterpret_cast<const Vector2 *>(_data._mem);
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 75316da63f..125173ea5c 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -645,6 +645,7 @@ public:
bool hash_compare(const Variant &p_variant) const;
bool booleanize() const;
String stringify(List<const void *> &stack) const;
+ String to_json_string() const;
void static_assign(const Variant &p_variant);
static void get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants);