views:

194

answers:

1

Hi, I am currently looking into writing a fast deesrialisation/parsing of a custom message format which are similar to BNF syntax. There are maybe 50 different objects involved. The grammar of the objects contains a recursive definition which is the biggest problem for me at the moment. Do you know any good examples or would you write your own lexer using regular expressions and parsing them using a FIFO queue for the embedded messages? In Perl I am at the moment converting the messages into JSON messages and use a generic parser, but I am not so sure if this makes sense on C#. Messages look like this: "{key1=value1|key2={key3=value3}}".

A: 

The following URL shows examples of serialization/deserialization of JSON in C# by Scott Gu and the .NET 3.5 Framework:

http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx

Right before the summary you will find this sentence:

Note: In addition to the JavaScriptSerializer class, .NET 3.5 also now includes a new System.Runtime.Serialization.DataContractJsonSerializer class that you can use for JSON serialization/deserialization.

Hope this helps:

Andrew

REA_ANDREW
Can one look at the source code for the JSON deserializer?
weismat
Yes. You can view the content of all .NET or any assemblies using this free tool: http://www.red-gate.com/products/reflector/ . It is not too useful if the assembly has be obfustiicated though
REA_ANDREW