{"id":6915,"date":"2014-05-11T17:43:57","date_gmt":"2014-05-11T17:43:57","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/lib-gdx-json-serializationexception-and-missing-no-arg-constructor-collection-of-common-programming-errors\/"},"modified":"2014-05-11T17:43:57","modified_gmt":"2014-05-11T17:43:57","slug":"lib-gdx-json-serializationexception-and-missing-no-arg-constructor-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/11\/lib-gdx-json-serializationexception-and-missing-no-arg-constructor-collection-of-common-programming-errors\/","title":{"rendered":"Lib Gdx json serializationexception and missing no-arg constructor-Collection of common programming errors"},"content":{"rendered":"<p>The exception message &#8220;Class cannot be created (missing no-arg constructor): com.bvo.easyBim.Model.Cursor&#8221; describes exactly what is going wrong.<\/p>\n<p>The Libgdx JSON code uses reflection to create instances of objects and initialize them. In your example, there must be a <code>com.bvo.easyBim.Model.Cursor<\/code> in the saved JSON file. So when reading that file, the JSON code needs to create an instance of a <code>Cursor<\/code> to put the data in. It assumes there is a no-argument constructor that it can use to create an empty <code>Cursor<\/code> (it cannot figure out which constructor would be appropriate otherwise). However, it seems that there is no such method.<\/p>\n<p>You will either have to add a no-argument constructor to <code>Cursor<\/code>, or you will have to add a custom serializer (see https:\/\/code.google.com\/p\/libgdx\/wiki\/JsonParsing#Customizing_serialization) that knows how to save a <code>Cursor<\/code> instance and knows the appropriate constructor to invoke when reading a <code>Cursor<\/code> back in.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The exception message &#8220;Class cannot be created (missing no-arg constructor): com.bvo.easyBim.Model.Cursor&#8221; describes exactly what is going wrong. The Libgdx JSON code uses reflection to create instances of objects and initialize them. In your example, there must be a com.bvo.easyBim.Model.Cursor in the saved JSON file. So when reading that file, the JSON code needs to create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6915","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6915"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6915\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}