开发者

Why does JsonArray.Parse return me primitives with quotes?

开发者 https://www.devze.com 2022-12-13 19:14 出处:网络
I expected the following code JsonArray.Parse(\"[\\\"cat\\\",\\\"dog\\\"]\")[0].ToString() to give me cat but it actually gives me \"cat\".

I expected the following code

JsonArray.Parse("[\"cat\",\"dog\"]")[0].ToString()

to give me cat but it actually gives me "cat".

Is this a bug or by design.

Interestingly there is a private value member which does give cat.

 (((System开发者_运维问答.Json.JsonPrimitive)(JsonArray.Parse("[\"cat\",\"dog\"]")[0]))).value

will give cat - but its private !

(JsonArray is in System.Json.dll which for Silverlight 4 is here : C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Json.dll)


Yes, it is by design.

http://msdn.microsoft.com/en-us/library/system.json.jsonprimitive_methods%28v=VS.95%29.aspx

ToString Saves (serializes) this JSON CLR type into text-based JSON. (Inherited from JsonValue.)

0

精彩评论

暂无评论...
验证码 换一张
取 消