Modified encodeAnonymousObject to also go through fields of class instance.

Maybe it would be a good idea to rename the function to just encodeObject? I didn't do it as I didn't want to do too big a change.
Also it should be possible to parse JSON directly to class instance (not anonymous object), just need to also store class name and have it available when parsing. Similar to how Haxe serialization works.