Skip to content

Deserialize particular object #141

@protyagov

Description

@protyagov

I am trying to deserialize a particular object from stream. Object looks like this:

{
"Tracker_Name":"xxxx x",
"Tracker_SearchTerm":"Wind Power",
"Tracker_SortBy":"Relevance"
}

Deserialize it like that:

using (TextReader reader = new StreamReader(stem)) 
    return NetJSON.NetJSON.Deserialize<T>(reader);

into the following object

public class Tracker {
        [NetJSONProperty("Tracker_Name")]
        public string Name { get; set; }

        [NetJSONProperty("Tracker_SearchTerm")]
        public string SearchTerm { get; set; }

        [NetJSONProperty("Tracker_SortBy")]
        public string SortBy { get; set; }
}

I get not null object where all properties are set to null. The strange thing is that it somehow reacts to value "xxxx x". If I have there instead "xxxxx" or "xxx xx" it works just fine. For some reason only certain combinations yield error. If JSON string has "Tracker_Name" as last param then first 2 params get correct value and name still be null.
If JSON string has space before " :" then deserializing works fine for any value.

The same manipulation with "Tracker_SearchTerm" param appear to have no affect on result. For some reason only Name property does that...

Not sure why this happens. Perhaps I need to setup something extra but I am not sure what...

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions