summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsdjson.cpp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-09-10 16:48:01 -0700
committerRider Linden <rider@lindenlab.com>2015-09-10 16:48:01 -0700
commit6a204b1bddc711b768d598c6ac0a16413f48d3c3 (patch)
treefe4e526394ad1571ea18c9c4de1e0a709143d6d8 /indra/llcommon/llsdjson.cpp
parenta471ae72e4b48a12cfeeba544afde9d078428f0d (diff)
MAINT-5575: Finished converting experience cache to singleton
MAINT-4952: Coverted VMM to coroutines
Diffstat (limited to 'indra/llcommon/llsdjson.cpp')
-rw-r--r--indra/llcommon/llsdjson.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index 2afdba388a..8caaaee534 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -76,3 +76,51 @@ LLSD LlsdFromJson(const Json::Value &val)
}
return result;
}
+
+//=========================================================================
+Json::Value LlsdToJson(const LLSD &val)
+{
+ Json::Value result;
+
+ switch (val.type())
+ {
+ case LLSD::TypeUndefined:
+ result = Json::Value::null;
+ break;
+ case LLSD::TypeBoolean:
+ result = Json::Value(static_cast<bool>(val.asBoolean()));
+ break;
+ case LLSD::TypeInteger:
+ result = Json::Value(static_cast<int>(val.asInteger()));
+ break;
+ case LLSD::TypeReal:
+ result = Json::Value(static_cast<double>(val.asReal()));
+ break;
+ case LLSD::TypeURI:
+ case LLSD::TypeDate:
+ case LLSD::TypeUUID:
+ case LLSD::TypeString:
+ result = Json::Value(val.asString());
+ break;
+ case LLSD::TypeMap:
+ result = Json::Value(Json::objectValue);
+ for (LLSD::map_const_iterator it = val.beginMap(); it != val.endMap(); ++it)
+ {
+ result[it->first] = LlsdToJson(it->second);
+ }
+ break;
+ case LLSD::TypeArray:
+ result = Json::Value(Json::arrayValue);
+ for (LLSD::array_const_iterator it = val.beginArray(); it != val.endArray(); ++it)
+ {
+ result.append(LlsdToJson(*it));
+ }
+ break;
+ case LLSD::TypeBinary:
+ default:
+ LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" << val.type() << ")." << LL_ENDL;
+ break;
+ }
+
+ return result;
+}