开发者

Why does JsonArray.Parse return me primitives with quotes?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜