admin管理员组

文章数量:1426226

I have some Json which seems perfectly valid when ran in JavaScript but fails when I try to parse it using Newtonsoft.parse in c#. I get the error parsing boolean value. I'm guessing newtonsoft doesn't like none string values which aren't integers or booleans.

in JavaScript:

var formDef = { "control" : formDef["c1"],  "c1" : "Button" }

in c#:

JObject.Parse("{\"control\":formDef[\"c1\"],\"c1\":\"Button\"}")

Many thanks.

I have some Json which seems perfectly valid when ran in JavaScript but fails when I try to parse it using Newtonsoft.parse in c#. I get the error parsing boolean value. I'm guessing newtonsoft doesn't like none string values which aren't integers or booleans.

in JavaScript:

var formDef = { "control" : formDef["c1"],  "c1" : "Button" }

in c#:

JObject.Parse("{\"control\":formDef[\"c1\"],\"c1\":\"Button\"}")

Many thanks.

Share Improve this question asked Feb 23, 2016 at 16:27 SaipH-SaipH- 51 silver badge4 bronze badges 1
  • I'd say similar, not dupicate, the linked question presents a serialization problem in addition of the deserialization one – Irwene Commented Feb 23, 2016 at 16:39
Add a ment  | 

1 Answer 1

Reset to default 3

formDef["c1"] is valid Javascript, not valid JSON. Try running your JSON through a linter to know if it's valid.

本文标签: javascriptNewtonsoft Jsonnet error parsing boolean valueStack Overflow