serializing a class to json
Started by
Chris Seto
, Feb 29 2012 06:28 AM
2 replies to this topic
#1
Posted 29 February 2012 - 06:28 AM
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.
Any ideas?
#2
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.
Any ideas?
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.
Attached Files
#3
Posted 12 June 2012 - 10:15 PM
This is a great, after lots of headaches with the netduino helpers library this worked great.
I just removed the serializing items as i had no need for them
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users