aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/JsonStore
diff options
context:
space:
mode:
authorMic Bowman2013-02-11 19:55:10 -0800
committerMic Bowman2013-02-11 19:55:10 -0800
commitd3b2cdc2b41833a338101a7f05eaa6f8d4dd5ef1 (patch)
tree8090cf651fab33abe29371b7e139f91ef6de3b81 /OpenSim/Region/OptionalModules/Scripting/JsonStore
parentAdd regression TestJsonSetValueJson() (diff)
downloadopensim-SC_OLD-d3b2cdc2b41833a338101a7f05eaa6f8d4dd5ef1.zip
opensim-SC_OLD-d3b2cdc2b41833a338101a7f05eaa6f8d4dd5ef1.tar.gz
opensim-SC_OLD-d3b2cdc2b41833a338101a7f05eaa6f8d4dd5ef1.tar.bz2
opensim-SC_OLD-d3b2cdc2b41833a338101a7f05eaa6f8d4dd5ef1.tar.xz
Fix handling of string values in JsonSetValueJson(). There are
some oddities with empty strings: the Json serializer treats them as default values and does not return them in serialized hashes.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/JsonStore')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs32
1 files changed, 31 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
index 3d715cc..82a4da7 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
@@ -198,7 +198,37 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
198 // ----------------------------------------------------------------- 198 // -----------------------------------------------------------------
199 public bool SetValue(string expr, string value, bool useJson) 199 public bool SetValue(string expr, string value, bool useJson)
200 { 200 {
201 OSD ovalue = useJson ? OSDParser.DeserializeJson(value) : new OSDString(value); 201 OSD ovalue;
202
203 // One note of caution... if you use an empty string in the
204 // structure it will be assumed to be a default value and will
205 // not be seialized in the json
206
207 if (useJson)
208 {
209 // There doesn't appear to be a good way to determine if the
210 // value is valid Json other than to let the parser crash
211 try
212 {
213 ovalue = OSDParser.DeserializeJson(value);
214 }
215 catch (Exception e)
216 {
217 if (value.StartsWith("'") && value.EndsWith("'"))
218 {
219 ovalue = new OSDString(value.Substring(1,value.Length - 2));
220 }
221 else
222 {
223 return false;
224 }
225 }
226 }
227 else
228 {
229 ovalue = new OSDString(value);
230 }
231
202 return SetValueFromExpression(expr,ovalue); 232 return SetValueFromExpression(expr,ovalue);
203 } 233 }
204 234