As much as it seems unwise to do so, I have started working on a JSON parser for .NET - why? Good question. Well, I have long used a certain library for doing "AJAX" with ASP.NET, and I don't much care for the way it handles some things with regards to dealing with client-side objects (i.e. JavaScript objects). Yes, there are other JSON-to-.NET libraries around, but what fun is that?
So, I am going to try to get something like this to work for myself. All I need to do is get a JSON string like "[1,2,3]" to convert to an integer array, right? Right! Not to mention getting any other JSON string to convert to an equivalent .NET type on the server, but that will be cake. ;) So, first thing I did was take the open-source and librerally-licensed JSON syntax checker implemented in C and convert it to C# (got the main file, JSON_checker.c done, haven't got to the UTF stuff yet). I ran it against all of the supplied tests (and a few of my own) and things are looking good (i.e. all the tests passed). This thing is implemented with a finite state machine - and it is hella-fast.
So, as it states on that site, the checker "could be adapted to produce a very fast JSON parser." Indeed. Using the state transition table and lots of stepping through the code and stepping through my brain, I have come up with a few ways (all of which need more work) of how I would create .NET objects from JSON using this tool. I am really having to reach back to my CS education to think about what data structures would be most appropriate for use in the process. Matching the json objects to their .NET counterparts is hopefully as simple as looking at the expected type and using reflection to instantiate it with the JSON data.
Well, anyway - who knows what will happen? My brain has been so fried lately that I don't know if I am heading down a dead-end or not. I want to create a simple, fairly bare-bones AJAX lib for use with ASP.NET that is built on top of MochiKit, since it is the best JavaScript library around. As much as I don't want to, I know someday I may need to learn Atlas, but I would rather not - it seems like it is going to be a pain in the rear. I am sure I will change my mind; after all, if Microsoft serves it to us on a platter, it must be good . . . right? :P Probably good like using DataSets as business objects...
Have you seen Script#, "a project for enabling script authoring via C#?!?!" Help me live, you have to be kidding me! I know it is hard to have code strewn across .js files, .aspx files, and .aspx.cs files, but I *really* don't like the idea of having all of my code in C# and have it magically converted to JavaScript. I mean, yeah, I suppose it is kind of cool in a weird, freaky geeky way, but I don't think I want to write code like that. Maybe I will sing a different tune a year or two from now, but something about it just seems . . . wrong. I am sure it is just me, I mean, Nikhil is a smart guy, much smarter than I, right? I'm pretty sure of it...99% at least.
Remember Me
a@href@title, b, blockquote@cite, i, strike, u
Disclaimer The opinions expressed herein are Jason Bunting's personal opinions, as they are presently constituted, and are subject to change and do not represent his employer's view in any way; feel free to disagree with him. Jason Bunting is not a doctor, and no advice/information presented on this website is intended to diagnose, treat or cure any disease. When you have health questions, always seek help from a qualified health practitioner or naturopathic physician. This information is provided as-is, without warranty, and is solely the opinion of Jason Bunting, whose opinions may differ from mainstream medical opinion.