help with output structure

Feb 18, 2009 at 2:38 AM
Edited Feb 18, 2009 at 2:39 AM

I have managed to output the following using SerializeObject:


[
{"abbreviation":"value1","name":"name-value1"},
{"abbreviation":"value2","name":"name-value2"},
{"abbreviation":"value3","name":"name-value3"},
{"abbreviation":"value4","name":"name-value4"},
{"abbreviation":"value4","name":"name=value5"}
]

I'm looking for the following structured output but don't know how to go about it:

{

"keys": ["abb_key0", "abb_key1", "abb_keyn"],

"abb_key0": { "name": String,"abbreviation": String },
"abb_key1": { "name": String,"abbreviation": String },
"abb_keyn": { "name": String,"abbreviation": String }

}

Any direction would be appreciated! I'm using vb.net - but if you only have a C# example I will convert.

Thanks so much in advance.


Coordinator
Feb 18, 2009 at 3:54 AM
To get JSON in that custom format you will need to manually write it.

I would recommend creating LINQ to JSON objects in the desired structure and then using ToString to get the JSON text.
Feb 19, 2009 at 6:58 PM
Is there any possibility of you providing sample code for how this is done? I haven't been able to structure it the same as I need and it's killing me!