Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(String)JToken vs JToken.ToString() #1242

Open
jeffrson opened this issue Mar 9, 2017 · 3 comments
Open

(String)JToken vs JToken.ToString() #1242

jeffrson opened this issue Mar 9, 2017 · 3 comments

Comments

@jeffrson
Copy link

jeffrson commented Mar 9, 2017

Except for #1241 there's a problem with the following code:

String js = "{ \"DateTime\": \"2017-03-07T17:26:40.352Z\" }";
var jo = JObject.Parse(js);
String ds1 = (String)jo["DateTime"];
String ds2 = jo["DateTime"].ToString();

ds1 is not equal to ds2 - while ds1 apparently has some english or american format, ds2 contains a localized version. I would expect that both values are equal.

@fqborges
Copy link

I found the same issue, and I made a test to isolate it:

[Fact]
void Test_DateAsString()
{
    string str = "{ \"value\" : \"2008-12-28T00:00:00\"  }";
    var json = JObject.Parse(str);
    Assert.Equal("2008-12-28T00:00:00", json.Value<string>("date"));
}

Since I read value as a string value, it should return the exact string.

@Lakritzator
Copy link

This is related to #904 right?

@fqborges
Copy link

Yes, it seems so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants