Question

Is it possible to provide somekind of custom contract resolver to the build-in JsonSerializer?

The response data is formatted as this:

{
  "name":"Rob Angelier"
}

The property i would like to set is: Name

The question is: How can i deserialize from camelcase to pascalcase notation?

Hope you can help me out!

Was it helpful?

Solution

You can get the name property with either:

string name = JsonObject.Parse(json)["name"];

Otherwise you can create a strong-typed class that matches the JSON to deserialize into, e.g:

class Contact { 
    public string Name { get; set; }
}
var contact = json.FromJson<Contact>();

In the ServiceStack JSON test suite you can find multiple different ways to deserialize the same thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top