c# - ServiceStack.Text DynamicJson fails to parse an array -


running following code:

var s = @"{ ""simple"": ""value"", ""obj"": { ""val"":""test"" }, ""array"": []"; var dyn = dynamicjson.deserialize(s); console.writeline(dyn.simple); console.writeline(dyn.obj); console.writeline(dyn.obj.val); console.writeline(dyn.array); 

prints:

"value" {"val":"test"} base {system.dynamic.dynamicobject}: {"val":"test"} "test" "[]" 

which means dyn.obj returns object can continue navigate through dyn.array returns string. meaning cannot iterate through list of objects inside.

what missing?

edit

i think have found issue. looking in github in pcl.dynamic.cs method yieldmember following:

private bool yieldmember(string name, out object result) {     if (_hash.containskey(name))     {         var json = _hash[name].tostring();         if (json.trimstart(' ').startswith("{", stringcomparison.ordinal))         {             result = deserialize(json);             return true;         }         result = json;         return _hash[name] == result;     }     result = null;     return false; } 

it takes care of converting values starting { deserialized (dynamic) object.

i know @mythz looks @ questions in stackoverflow maybe can chime in thoughts. seems pretty simple handle when json starts [ right?

edit 2

i'm considering bug. i've made fix in code , submitted pull request. in case curious:

https://github.com/servicestack/servicestack.text/pull/442

it indeed bug has been accepted servicestack.text's source code.

https://github.com/servicestack/servicestack.text/commit/7cd06d3e90bcbfd244af525ed7f584bd4badc31e


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -