KBD

Keith Devens .com

Thursday, March 18, 2010 Flag waving
"It's like a condom; I'd rather have it and not need it than need it and not have... – some chick in Alien vs. Predator, when asked why she always carries a gun

Tag: Json

Daily link icon Thursday, April 23, 2009

JSON in .NET 3.5

.NET 3.5: JSON Serialization using the DataContractJsonSerializer. Very helpful article.

However, Microsoft's built-in JSON serialization doesn't even serialize the built-in Dictionary class in a useful way.

var foo = new Dictionary<string,string>();
foo.Add("one", "uno");
foo.Add("two", "dos");
var json = new System.Runtime.Serialization.Json.DataContractJsonSerializer(foo.GetType());
var stream = new MemoryStream();
json.WriteObject(stream, foo);

Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));

gives:

[{"Key":"one","Value":"uno"},{"Key":"two","Value":"dos"}]

Idiots.

Edit: FWIW, the reason behind it is that Microsoft wrote their JSON serialization as a half-assed subclass of their XML serialization, so it thinks everything's an "infoset". Infosets don't have associative arrays, hence their representation of one as an array of key value pairs.

JSON is kind of an important technology, and Microsoft allocated one day of a programmer's time to half-ass it into the .NET class libraries.

Daily link icon Monday, September 22, 2008

  1. My one question about JSON is why it's disallowed to have the root element be any valid JSON element, instead of only allowing object or array.

       (0) Tags: [Json]

Daily link icon Monday, June 23, 2008

  1. Jayrock: JSON and JSON-RPC for .NET.

       (0) Tags: [ASP.NET, Json]

Daily link icon Friday, April 18, 2008

  1. Web Dev Bros » Blog Archive » Generate JSON from VBScript (ASP) datatypes.

       (0) Tags: [Json, VBScript]

Daily link icon Tuesday, October 16, 2007

  1. DBSlayer (via).

    The DBacesslayer aka DBSlayer aka Släyer (as we like to call it when we're feeling ironically heavy metal) is a lightweight database abstraction layer suitable for high-load websites where you need the scalable advantages of connection pooling. Written in C for speed, DBSlayer talks to clients via JSON over HTTP, meaning it's simple to monitor and can swiftly interoperate with any web framework you choose.

       (0) Tags: [Databases, Json]

Daily link icon Monday, April 9, 2007

  1. James Clark's Random Thoughts: XML and JSON (via). JSON is fine, l2p. Smiley

       (0) Tags: [Json, XML]

Daily link icon Tuesday, March 6, 2007

  1. json-taglib - Overview (via Simon). LOL.

       (0) Tags: [Funny, Java, Json]

Daily link icon Tuesday, December 26, 2006

On Semantics

People like this commenter on Simon's blog drive me nuts enough to make me want to post about it.

you clearly do not understand the idea of a 'semantic' web. Using xml makes it possible to use that information on other places, you can include it in an xml document, like xhtml, using xlink to point to certain data elements. And another advantages: Your data is tagged. You have given it semantic meaning. [emphasis mine]

Please. As if <foo>bar</foo> has any more "semantic meaning" [1] than "foo": "bar". Symbols have meaning when some agent imparts meaning to them. I.e. something has meaning when some person or thing understands it to have a certain meaning. Just because something is "tagged" doesn't give that something any meaning. The tags have to be interpreted by some intelligence, that intelligence being either a person, or by proxy, code that a person has written to "understand" those tags by performing some action based on them. "foo":... can be interpreted just the same as <foo>...</foo> can. Get off your high horse.

(Incindentally, the epistemelogical need for unity of meaning, to me, is a very strong argument for God as the foundation of meaning. But that's a separate discussion.)

Footnotes:
[1]: this phrase irks the hell out of me as well. It's redundant. Only people who want to use more words to make themselves sound intelligent talk about "semantic meaning"

Daily link icon Wednesday, November 8, 2006

  1. PHP: JSON Functions - Manual. Ooh, JSON is now built into PHP. Rock on. (Via Simon)

       (0) Tags: [Json, PHP]

Daily link icon Wednesday, August 30, 2006

Json.NET - Newtonsoft

Json.NET - Newtonsoft, a C# implementation of JSON. Looks really good from their example... about to try it out.

Update: based on testing so far, it works great. Their example output is incorrect however. It uses single quotes, when only double quotes are allowed in JSON. But the code in fact does the right thing.

Note that the library will generate invalid JSON and include language-specific types in it, such as a date. And that's actually desirable, since if you're just using it as serialization for your own code you get what you want, and can be careful and not use language-specific types if you need to share with others.

Daily link icon Tuesday, August 1, 2006

  1. Turns out JSON now has an RFC! Via Simon.

       (0) Tags: [Json]
March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.136s.

(Used 10 db queries)