RESTful JSON and XML Serialization

Folks, I’d like to propose a major community effort around serialization for interaction with REST web services, assuming there is not a solution available.

Justification:
The whole point of IoT is connected devices, communicating with web services, etc. Depending on the service, one may need to get/post JSON or XML. This means serialize/deserialize JSON/XML to poco objects, hashtables, arrays, something. This warrants serious framework/toolkit support, there is a LOT of data coming and going that needs handling.

Observation:
-XML read/write using System.Xml in NETMF is really verbose, and not generic (too specific on a case-by-case usage)
-I therefore really miss the xml serializer from the full .NET framework. Can’t we get a stripped down version of this?
-JSON serialization is non-existant, unless I missed something?

Community Projects:
-XML: none that I know of
-JSON: on codeplex there is JSON.Net, but its pretty tied up in stuff that NETMF doesn’t support. Looks non-trivial to scope down
-I have seen hints of JSON serializers, but still no deserializers (see http://www.tinyclr.com/forum/topic?id=3518)
-I tried the parser/deserializer from here (http://netduinohelpers.codeplex.com/) but to no avail - failures on the simplest tests

Anyone been down this path, have solutions? I’m happy to be corrected that these problems have already been solved.

In my opinion, Microsoft should provide this as an added layer in the framework, at least as a “toolkit” lib if not in NETMF itself. But, I know how busy that team is… :slight_smile:

(edited subject to match discussion better)

I (among others) made a JSON serialisation class, go to Codeshare and search for JSON.
XML serialization generates data that is much larger then JSON, given networkspeed and memory limitations on the embedded devices, I would stick to JSON.

As JSON is also very verbose the best format for embedded systems would be csv or just ASCII
JSON is great when you use javascript, for all other purposes it is not really suited.
Once there was an invention called ASCII that has codes that are not part of the text charaacter sets.
Like SOH SOT ETX etc… these can be used for a very compact serialisation without the possibility to mix up text and codes
xml:

John
Doe

JSON:
{ “firstname”: “John”, “lastname”: “Doe” }

CSV:
“John”,“Doe”

ASCII:
John<0x1F>Doe<0x1E>
Where the 0x1F and 0x1E stand unit seperator and record seperator.

Guess which one is the most easy to code/decode and needs the least amount of data.

Which would be the easiest to parse?

[quote=“Brainless”]
xml:

John
Doe
[/quote]

Or, if you own both the serialization and deserialization code:

…or even…

Guys, I think you may have missed the point! This is about interacting with RESTful web services, you are not afforded the luxury of changing the standards, but must conform to the format that is used or you can’t play in the world wide playground. Otherwise, sure, absolutely there are better ways to communicate and store data on micro-devices. But thats a different ball game.

WouterH, I found this (http://www.tinyclr.com/forum/topic?id=3518) and I will try that out, as well as another lib I found called “IndianaJones.JSON” here: http://www.tinyclr.com/codeshare/entry/357

Still, this is just JSON. I’m looking for XML as well, and I am also rallying for a robust, tested solution. I’m hoping for one of 3 things:
[ol]There are robust solutions out there
Microsoft will provide such in their next release (given their interest not only in NETMF, but also their own web services, Azure, etc)
The community (including myself) will build out a robust solution (which might indeed include building on existing projects out there)[/ol]

Thoughts?

JSON generation library
http://www.tinyclr.com/codeshare/entry/282

It’s because the most i do is through GPRS mobile communication, so i am biased. If your main solutions are connection with (a)sdl or faster this is not important at all, except that microcomputers are slower with deseriliasation especiall XML and JSON when you are not ina Javascript environment and that can be a point to consider. It is still the slowest part of .net also on servers.
The amount of data in that case is very important and is the difference between a snappy application or a dreadfull slow one. Not to forget that telecom companies are slowly retreating from their unlimited data plans (at least in europe), because otherwise voip is taking over there voice business.
The way i solve it is using a proxy server to get that information in whatever format it is available and break it down to its essentials, and that is information, not formatting, soap envelopes, object notation or whatever that is not information.

Perf concerns are totally valid. I also think proxy servers are the way to go if the scenario allows. Many scenarios do not afford proxy, thus we need good solutions in NETMF.

UseCase:
Device connects directly to various social networks (performs auth/registration, gets basic data via JSON or sometimes XML) and performs some sort of cool actions or displays something.

To further illustrate, what if I build a simple “woot light” type device that lights up any time someones shares a link on my Facebook wall (for example) and want to sell that to a bunch of nerds as a sort of “hobby small biz”? I sure don’t want to run a proxy server, just sell a device, period.

Backstory:
I’m currently using my FEZ Spider to connect to Facebook, Google, Twitter, and Windows Live. All I am doing is a few simple tasks (accessing some bits of info for the user on these services). No way do I want to proxy all this when there is such a great networking stack in NETMF that can handle it all (which it does). And no, I am not building a doomed to fail woot-light business (that was just to illustrate :slight_smile: ). EMX makes it just so darn doable, granted, not as cheap, tiny or fast performing as one might like. In developing this, the biggest pain points have been lack of (de)serialization of all this REST data, and lack of DateTime.Parse()! :slight_smile:

this link is apparently dead, was there ever a json library developed?
thanks

Welcome to the forum Axa.

If you go to the search box in the menu bar above, change the search to “codeshare” and type XML, you’ll see relevant results returned. This thread is an old archived one, 4+ years old, and the URLs have changed from tinyclr.com to just be part of the GHIelectronics domain.