From 6d825d7ea22f5accd1324a4ef8800eddb8dc86da Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Fri, 8 Feb 2013 15:46:42 -0800 Subject: Broaden the internal OSD type checks to parse JSON that has non string values. --- .../Scripting/JsonStore/JsonStore.cs | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore') diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs index 088d0cd..5c89717 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs @@ -145,7 +145,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore if (result == null) return false; - if (useJson || result.Type == OSDType.String) + if (useJson || OSDBaseType(result.Type)) return true; return false; @@ -531,7 +531,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore return true; } - if (result.Type == OSDType.String) + if (OSDBaseType(result.Type)) { value = result.AsString(); return true; @@ -562,6 +562,33 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore /// /// // ----------------------------------------------------------------- + protected static bool OSDBaseType(OSDType type) + { + // Should be the list of base types for which AsString() returns + // something useful + if (type == OSDType.Boolean) + return true; + if (type == OSDType.Integer) + return true; + if (type == OSDType.Real) + return true; + if (type == OSDType.String) + return true; + if (type == OSDType.UUID) + return true; + if (type == OSDType.Date) + return true; + if (type == OSDType.URI) + return true; + + return false; + } + + // ----------------------------------------------------------------- + /// + /// + /// + // ----------------------------------------------------------------- protected static int ComputeSizeOf(OSD value) { string sval; -- cgit v1.1