Quantcast
Channel: Json.NET
Viewing all articles
Browse latest Browse all 1767

New Post: Error on selectToken when Whitespace appears in property name in latest version

$
0
0
Hi,
I have just upgraded from version 5.0.1 to 6.0.3 and one of the things that has now started failing is when there is a space in the property name for eg

public class Product
{
    /// <summary>
    /// Gets or sets the expiry.
    /// </summary>
    public DateTime Expiry { get; set; }

    /// <summary>
    /// Gets or sets the name.
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// Gets or sets the sizes.
    /// </summary>
    [JsonProperty(PropertyName = "Test Space")]
    public string[] Sizes { get; set; }
} 
To prove this issue, i serialize the object to a json and parse it back into a JObject
string json = JsonConvert.SerializeObject(product);
        Console.WriteLine(json);
        Console.ReadLine();
        JObject jobj = JObject.Parse(json);
        var p = jobj.SelectToken("Test Space");

However with the latest version i get a parse error on the SelectToken statement. This works fine and expected and returns the whitespaced token with the version 5.0.1. Any ideas on whats changed?

Viewing all articles
Browse latest Browse all 1767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>