How to force Json.Net to put an integer value into a string field?
Posted
by Earlz
on Stack Overflow
See other posts from Stack Overflow
or by Earlz
Published on 2010-06-11T04:20:45Z
Indexed on
2010/06/11
4:22 UTC
Read the original article
Hit count: 280
Hello, in using Json.Net I have a class like this
class Foo{
public string name;
public string value;
}
and I have a JSON string that looks like this:
[{"name": "some name","value": "1"}]
The problem with this is that Json.Net detects "1"
as being an integer(due to ambiguities with JSON) and will refuse to put it into the string value
of Foo
How can I override this behavior so that it will put the string "1"
into value
?
© Stack Overflow or respective owner