vertis.io

LitJSON causes System.MissingMethodException : No parameterless constructor defined for this object.

Introduction

user

Luke Chadwick

Geek since birth. Futurist. Lover. Idealist.


LitJSON causes System.MissingMethodException : No parameterless constructor defined for this object.

Posted by Luke Chadwick on .
Featured

LitJSON causes System.MissingMethodException : No parameterless constructor defined for this object.

Posted by Luke Chadwick on .

Filing another report under hard to google errors, which seems to be my primary reason for posting on this blog these days.

Was working with LitJSON in C# to deserialize an API response. When I started getting System.MissingMethodException : No parameterless constructor defined for this object..

This error message is too generic to Google, and there is nothing in the results related to LitJSON really. Turned out I had a really simple problem though.

My class was something like this

 
public class Foo {
  public string bar
}
 

When in reality to JSON was:

 
{
  "bar": {}
}
 

Calling:

var jsonObject = JsonMapper.ToObject<Foo>(res.body); 

Works much better when you’re not trying to shove a Map into a string.

user

Luke Chadwick

http://vertis.io

Geek since birth. Futurist. Lover. Idealist.