serializing a class to json
Posted 29 February 2012 - 06:28 AM
Posted 29 February 2012 - 06:23 PM
I'm doing a small AJAX webserver project on my Netduino, and I need a way to convert a very large class into json, or some other serialized format for consumption on the client end.
I was thinking about looking into reflections to iterate on each field contained in the class, but I'd like to see if there was any better way to handle this.
The alternative is some sort of string template system, or even worse, manually creating the json string.
I'm in the same boat, using a json object to control config data for my aquarium controller frontend.
The Netduino Helpers have a JSON object in them, but I believe they're currently buggy.
I pulled a JSON parser from here and modified it to compile under .NETMF 4.2 (need to flash your N+ to latest firmware) and it's got a Serialize / Deserialize.
Objects are Hashtables and ArrayLists, so not an amazing amount of overhead.
Worth trying out, depending on how big your class is. You may even want to look at an intermediate object instead of serializing a large class.
Posted 12 June 2012 - 10:15 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users