Rectangle 27 250

JsonConvert.DeserializeObject<RootObject>(string json);

Json.NET documentation: Serializing and Deserializing JSON with Json.NET

Visual Studio also has a Paste JSON as Classes option in the Edit-Paste Special menu.

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 64

Have you tried using the generic DeserializeObject method?

JsonConvert.DeserializeObject<MyAccount>(myjsondata);

Any missing fields in the JSON data should simply be left NULL.

If the JSON string is an array, try this:

var jarray = JsonConvert.DeserializeObject<List<MyAccount>>(myjsondata);
jarray
List<MyAccount>

The exception you're getting isn't consistent with an array of objects- I think the serializer is having problems with your Dictionary-typed accountstatusmodifiedby property.

Try excluding the accountstatusmodifiedby property from the serialization and see if that helps. If it does, you may need to represent that property differently.

Documentation: Serializing and Deserializing JSON with Json.NET

Thanks. However I get an error of "Cannot deserialize JSON array into type 'System.String'." when it's trying to deserialize (for example) the JSON givenname array into the class GivenName string. The JSON attributes that I have defined as string in the C# class are only ever single element arrays. This is why I started picking out the values one by one as I ran in to this kind of issue during the deserialize process. Other magic that I am overlooking?

So ... DateTime AccountStatusExpiration (for instance) is not nullable as defined in the code. What would it take to make it nullable? Simply change DateTime to DateTime??

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 41

You can use the C# dynamic type to make things easier. This technique also makes re-factoring simpler as it does not rely on magic-strings.

The json string below is a simple response from an http api call and it defines two properties: Id and Name.

{"Id": 1, "Name": "biofractal"}

Use JsonConvert.DeserializeObject<dynamic>() to deserialize this string into a dynamic type then simply access its properties in the usual way.

var results = JsonConvert.DeserializeObject<dynamic>(json);
var id = results.Id;
var name= results.Name;
using Newtonsoft.Json;

Love the use of <dynamic>. However, I had to do this to get it working: result["Id"].Value and result["Name"].Value

Although dynamic is a nice alternative, the above examples are not using 'magic strings' but are instead using strongly typed generics which are updated during normal VS refactoring techniques (unless inside a View in MVC which is outside the scope of this question).

You still have 'magic strings', they now are just hidden by the use of dynamic!

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 1

I don't know JSON.NET but I can tell that you have an array of objects which have a different structure than your VB.NET class defines.

[
  {
    "finalist": {
      "id": 12,
      "vote_percentage": "28"
    }
  },

  {
    "finalist": {
      "id": 13,
      "vote_percentage": "6"
    }
  },

  ...
]

I guess (as I have very little knowledge of the .NET platform) that JSON.NET requires a list of instances of a class with the same structure - so a class definition like this (pseudocode):

class item
    public property finalist as result

class result
    public property id as Integer
    public property vote_percentage as String

What you might also want to do is simply get rid of the item class and use result objects directly like this in your JSON:

[
  {
    "id": 12,
    "vote_percentage": "28"
  },

  {
    "id": 13,
    "vote_percentage": "6"
  },

  ...
]

That way, you have a simplified array of objects representing result instances, without seemingly useless "wrapper objects" (i.e. those representing item instances).

Problems deserializing JSON data in VB.NET - Stack Overflow

vb.net json json.net deserialization
Rectangle 27 8

JsonConvert.PopulateObject(json, obj);

here: json is the json string,obj is the target object. See: example

Note: PopulateObject() will not erase obj's list data, after Populate(), obj's list member will contains its original data and data from json string

it's PopulateObject - Populate is not in the object model.

Does not work in complex c# objects.

This worked PERFECT for me! I was having issues where I had a pretty complex JSON string, when I tried to cast it to C# objects, anything marked as 'NotNull' would be missing from the object, even though it was present in the JSON string to begin with. Very strange. I used this method and it worked PERFECT!

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 5

data[totalItems].TIT2
data[totalItems-1].TIT2

Array indexes starts with 0. so you need to do length-1 for the last item. data[totalItems] will go out of bounds and you will get an error as you access undefined.TIT2 effectively.

This api doesnt seem to support JSONP. if you fire the ajax with jquery, it appends a callback string to the url for jsonp callback.

But the response doesnt get wrapped in the function with the callback name, ideally the response should be:

jQuery19105709207213949412_1373047199605(jsonData);

But it doesn't, instead it just gives the json response as is.

@Jody: It seems that the URL does not return JSONP. You cannot use JSONP if the server does not support it. You have to proxy the request through your server.

if you set a callback response should come in a wrapper if it has to suuport jsonp

Boom. It works! Now I guess the only problem is the heavy request usage on both my server and the external server.

jquery - Need help getting JSON data last item - Stack Overflow

jquery jsonp
Rectangle 27 3

Building off of bbant's answer, this is my complete solution for deserializing JSON from a remote URL.

using Newtonsoft.Json;
using System.Net.Http;

namespace Base
{
    public class ApiConsumer<T>
    {
        public T data;
        private string url;

        public CalendarApiConsumer(string url)
        {
            this.url = url;
            this.data = getItems();
        }

        private T getItems()
        {
            T result = default(T);
            HttpClient client = new HttpClient();

            // This allows for debugging possible JSON issues
            var settings = new JsonSerializerSettings
            {
                Error = (sender, args) =>
                {
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                }
            };

            using (HttpResponseMessage response = client.GetAsync(this.url).Result)
            {
                if (response.IsSuccessStatusCode)
                {
                    result = JsonConvert.DeserializeObject<T>(response.Content.ReadAsStringAsync().Result, settings);
                }
            }
            return result;
        }
    }
}

Usage would be like:

ApiConsumer<FeedResult> feed = new ApiConsumer<FeedResult>("http://example.info/feeds/feeds.aspx?alt=json-in-script");
FeedResult

Here is a screenshot of the settings I used, allowing for weird property names which the web version could not account for.

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 2

It might help to look at the formatted JSON. I pasted the URL from your code into the validator window at JSONLint.com and clicked "Validate". Here is the result:

{
    "follows": [
        {
            "created_at": "2014-10-02T17:15:10Z",
            "_links": {
                "self": "https://api.twitch.tv/kraken/users/sleepyynet/follows/channels/seeingblue"
            },
            "user": {
                "_id": 41403351,
                "name": "sleepyynet",
                "created_at": "2013-03-16T19:42:01Z",
                "updated_at": "2014-10-07T19:28:33Z",
                "_links": {
                    "self": "https://api.twitch.tv/kraken/users/sleepyynet"
                },
                "display_name": "SleepyyNet",
                "logo": "http://static-cdn.jtvnw.net/jtv_user_pictures/sleepyynet-profile_image-96061b55b0da4c11-300x300.png",
                "bio": "Zzz...The Tired One",
                "type": "user"
            }
        }
    ],
    "_total": 14,
    "_links": {
        "self": "https://api.twitch.tv/kraken/channels/seeingblue/follows?direction=DESC&limit=1&offset=0",
        "next": "https://api.twitch.tv/kraken/channels/seeingblue/follows?direction=DESC&limit=1&offset=1"
    }
}

You can see from the above that the JSON response object contains three properties: follows, _total, and _links. The follows property contains an array. That array contains an object, which has three properties: created_at, _links and user. created_at is a string containing a date, while user and _links are both objects containing yet more properties.

In your first example, you're doing this:

Dim stream As JToken = root("user")
Dim game As String = stream("name").ToString()

This fails because there is no user property at the root level of the JSON, so root("user") returns null. You get an exception when you attempt to use the null stream variable on the following line.

In your second example, you're doing this:

Dim stream As JToken = root("follows")
Dim game As String = stream("created_at").ToString()

This fails because root("follows") returns an array. You can't index a JArray with a string name; you must use a numeric index (or else iterate over the array using a For Each loop).

So how can we make this work? Let's take your first example. To get the name of the user in the first item of the follows array in the root of the response, you could do this:

Another way to do the same thing with less code is to use the handy SelectToken method to navigate directly to the desired JToken using a path syntax:

Dim root As JToken = JToken.Parse(json)
Dim name As String = root.SelectToken("follows[0].user.name")
MsgBox(name)

Of course, both of the above examples assume that you already have the index of array item you want. If there's only one item, no problem-- the index is 0. But what if there are multiple items in the array? In that case, you'll probably want to do your processing in a loop instead. Here's an example which will display the names of all users following "seeingblue".

Dim url As String = "https://api.twitch.tv/kraken/channels/seeingblue/follows"
Dim json As String = New WebClient().DownloadString(url)
Dim root As JToken = JToken.Parse(json)
Dim sb As New StringBuilder()

For Each item As JToken In root("follows")
    sb.AppendLine(item.SelectToken("user.name"))
Next

MsgBox(sb.ToString())

Thank you, very easy to understand. I will hash over this for a few hours and I'm sure I can get something working out of it.

Organizing data using JSON.NET in VB.NET - Stack Overflow

vb.net json.net
Rectangle 27 52

Read and write JSON files with Python 2+3; works with unicode

# -*- coding: utf-8 -*-
import json

# Make it work for Python 2+3 and with Unicode
import io
try:
    to_unicode = unicode
except NameError:
    to_unicode = str

# Define data
data = {'a list': [1, 42, 3.141, 1337, 'help', u''],
        'a string': 'bla',
        'another dict': {'foo': 'bar',
                         'key': 'value',
                         'the answer': 42}}

# Write JSON file
with io.open('data.json', 'w', encoding='utf8') as outfile:
    str_ = json.dumps(data,
                      indent=4, sort_keys=True,
                      separators=(',', ': '), ensure_ascii=False)
    outfile.write(to_unicode(str_))

# Read JSON file
with open('data.json') as data_file:
    data_loaded = json.load(data_file)

print(data == data_loaded)

Explanation of the parameters of json.dump:

indent
  • sort_keys: sort the keys of dictionaries. This is useful if you want to compare json files with a diff tool / put them under version control.
separators
{
    "a list":[
        1,
        42,
        3.141,
        1337,
        "help",
        ""
    ],
    "a string":"bla",
    "another dict":{
        "foo":"bar",
        "key":"value",
        "the answer":42
    }
}
.json
  • CSV: Super simple format (read & write)

In case you are rather looking for a way to make configuration files, you might want to read my short article Configuration files in Python

Note that force_ascii flag is True by default. You'll have unreadable 6-bytes "\u20ac" sequences for each in your json file (as well as of any other non-ascii character).

Why do you use open for the reading but io.open for writing? Is it possible to use io.open for reading as well? If so, what parameters should be passed?

python - How do I write JSON data to a file? - Stack Overflow

python json
Rectangle 27 52

Read and write JSON files with Python 2+3; works with unicode

# -*- coding: utf-8 -*-
import json

# Make it work for Python 2+3 and with Unicode
import io
try:
    to_unicode = unicode
except NameError:
    to_unicode = str

# Define data
data = {'a list': [1, 42, 3.141, 1337, 'help', u''],
        'a string': 'bla',
        'another dict': {'foo': 'bar',
                         'key': 'value',
                         'the answer': 42}}

# Write JSON file
with io.open('data.json', 'w', encoding='utf8') as outfile:
    str_ = json.dumps(data,
                      indent=4, sort_keys=True,
                      separators=(',', ': '), ensure_ascii=False)
    outfile.write(to_unicode(str_))

# Read JSON file
with open('data.json') as data_file:
    data_loaded = json.load(data_file)

print(data == data_loaded)

Explanation of the parameters of json.dump:

indent
  • sort_keys: sort the keys of dictionaries. This is useful if you want to compare json files with a diff tool / put them under version control.
separators
{
    "a list":[
        1,
        42,
        3.141,
        1337,
        "help",
        ""
    ],
    "a string":"bla",
    "another dict":{
        "foo":"bar",
        "key":"value",
        "the answer":42
    }
}
.json
  • CSV: Super simple format (read & write)

In case you are rather looking for a way to make configuration files, you might want to read my short article Configuration files in Python

Note that force_ascii flag is True by default. You'll have unreadable 6-bytes "\u20ac" sequences for each in your json file (as well as of any other non-ascii character).

Why do you use open for the reading but io.open for writing? Is it possible to use io.open for reading as well? If so, what parameters should be passed?

python - How do I write JSON data to a file? - Stack Overflow

python json
Rectangle 27 1

You can try checking some of the class generators online for further information. However, I believe some of the answers have been useful. Here's my approach that may be useful.

The following code was made with a dynamic method in mind.

dynObj = (JArray)JsonConvert.DeserializeObject(nvm);

        foreach (JObject item in dynObj)
        {
            foreach (JObject trend in item["trends"])
            {
         Console.WriteLine("{0}-{1}-{2}", trend["query"], trend["name"], trend["url"]);

            }
        }

This code basically allows you to access members contained in the Json string. Just a different way without the need of the classes. query, trend and url are the objects contained in the Json string.

You can also use this website. Don't trust the classes a 100% but you get the idea.

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 1

I found my I had built my object incorrectly. I used http://json2csharp.com/ to generate me my object class from the JSON. Once I had the correct Oject I was able to cast without issue. Norbit, Noob mistake. Thought I'd add it in case you have the same issue.

Deserializing JSON data to C# using JSON.NET - Stack Overflow

c# json json.net deserialization
Rectangle 27 1

As mentioned in the comments this feed didn't support JSONP. So instead of pulling directly from the StreamON feed I did the following to write that feed data to my own server and effectively copy the feed:

file_put_contents("playlist.json", fopen("http://cjzn.streamon.fm/metadata/recentevents/CJZN-48k.json", 'r'));

So now playlist.json is located on my server and I can pull from that using JSON. I just have to regularly write the external feed to my server.

A hat tip also to the commenters about my problem with retrieving the last item in the feed and forgetting to subtract 1 as the index starts at 0 and not 1. Thanks guys!

jquery - Need help getting JSON data last item - Stack Overflow

jquery jsonp
Rectangle 27 157

I suspect the primary reason it's there is control. It forces you to retrieve the data via Ajax, not via JSON-P or similar (which uses script tags, and so would fail because that for loop is infinite), and thus ensures that the Same Origin Policy kicks in. This lets them control what documents can issue calls to the API specifically, only documents that have the same origin as that API call, or ones that Facebook specifically grants access to via CORS (on browsers that support CORS). So you have to request the data via a mechanism where the browser will enforce the SOP, and you have to know about that preface and remove it before deserializing the data.

So yeah, it's about controlling (useful) access to that data.

Thanks for answering T.J Crowder. I'm not clear about the need to defeat attempts to deserialize, how does it help in security and what kind of attack it prevents?

@mridkash: The only thing I can think of is that they don't want people using that API via JSON-P, which uses script tags to get around the Same Origin Policy. Also, they apparently only want the result consumed by someone who knows about the for loop, since of course that will break any standard JSON decoder (and in a really mean way if the decoder relies on eval). So that API is useless except when retrieved via ajax, and by someone who knows to remove that preface. Perhaps it's meant to only be used by their client-side code and they change the marker periodically...

@mridkash: Yeah, but remember it only controls misuse of the data via a web browser. Anyone who wants to can get the data manually, or use a non-browser-based tool to retrieve the text and use it in an automated process (even create a reflector that strips off the prefix). So it's not like it's really secure, just making it awkward for people. And a reflector would eventually show up in your logs as a conspicuously active client. :-)

Why not use /* as the prefix?

@Crowder: In older browsers one can override the Array() function in ways that allow you to catch the data that is passed. This means that you can't always assume that JSON literals evaluated in script tags don't leak.

What does a Ajax call response like 'for (;;); { json data }' mean? - ...

ajax json facebook
Rectangle 27 157

I suspect the primary reason it's there is control. It forces you to retrieve the data via Ajax, not via JSON-P or similar (which uses script tags, and so would fail because that for loop is infinite), and thus ensures that the Same Origin Policy kicks in. This lets them control what documents can issue calls to the API specifically, only documents that have the same origin as that API call, or ones that Facebook specifically grants access to via CORS (on browsers that support CORS). So you have to request the data via a mechanism where the browser will enforce the SOP, and you have to know about that preface and remove it before deserializing the data.

So yeah, it's about controlling (useful) access to that data.

Thanks for answering T.J Crowder. I'm not clear about the need to defeat attempts to deserialize, how does it help in security and what kind of attack it prevents?

@mridkash: The only thing I can think of is that they don't want people using that API via JSON-P, which uses script tags to get around the Same Origin Policy. Also, they apparently only want the result consumed by someone who knows about the for loop, since of course that will break any standard JSON decoder (and in a really mean way if the decoder relies on eval). So that API is useless except when retrieved via ajax, and by someone who knows to remove that preface. Perhaps it's meant to only be used by their client-side code and they change the marker periodically...

@mridkash: Yeah, but remember it only controls misuse of the data via a web browser. Anyone who wants to can get the data manually, or use a non-browser-based tool to retrieve the text and use it in an automated process (even create a reflector that strips off the prefix). So it's not like it's really secure, just making it awkward for people. And a reflector would eventually show up in your logs as a conspicuously active client. :-)

Why not use /* as the prefix?

@Crowder: In older browsers one can override the Array() function in ways that allow you to catch the data that is passed. This means that you can't always assume that JSON literals evaluated in script tags don't leak.

What does a Ajax call response like 'for (;;); { json data }' mean? - ...

ajax json facebook
Rectangle 27 157

I suspect the primary reason it's there is control. It forces you to retrieve the data via Ajax, not via JSON-P or similar (which uses script tags, and so would fail because that for loop is infinite), and thus ensures that the Same Origin Policy kicks in. This lets them control what documents can issue calls to the API specifically, only documents that have the same origin as that API call, or ones that Facebook specifically grants access to via CORS (on browsers that support CORS). So you have to request the data via a mechanism where the browser will enforce the SOP, and you have to know about that preface and remove it before deserializing the data.

So yeah, it's about controlling (useful) access to that data.

Thanks for answering T.J Crowder. I'm not clear about the need to defeat attempts to deserialize, how does it help in security and what kind of attack it prevents?

@mridkash: The only thing I can think of is that they don't want people using that API via JSON-P, which uses script tags to get around the Same Origin Policy. Also, they apparently only want the result consumed by someone who knows about the for loop, since of course that will break any standard JSON decoder (and in a really mean way if the decoder relies on eval). So that API is useless except when retrieved via ajax, and by someone who knows to remove that preface. Perhaps it's meant to only be used by their client-side code and they change the marker periodically...

@mridkash: Yeah, but remember it only controls misuse of the data via a web browser. Anyone who wants to can get the data manually, or use a non-browser-based tool to retrieve the text and use it in an automated process (even create a reflector that strips off the prefix). So it's not like it's really secure, just making it awkward for people. And a reflector would eventually show up in your logs as a conspicuously active client. :-)

Why not use /* as the prefix?

@Crowder: In older browsers one can override the Array() function in ways that allow you to catch the data that is passed. This means that you can't always assume that JSON literals evaluated in script tags don't leak.

What does a Ajax call response like 'for (;;); { json data }' mean? - ...

ajax json facebook
Rectangle 27 156

I suspect the primary reason it's there is control. It forces you to retrieve the data via Ajax, not via JSON-P or similar (which uses script tags, and so would fail because that for loop is infinite), and thus ensures that the Same Origin Policy kicks in. This lets them control what documents can issue calls to the API specifically, only documents that have the same origin as that API call, or ones that Facebook specifically grants access to via CORS (on browsers that support CORS). So you have to request the data via a mechanism where the browser will enforce the SOP, and you have to know about that preface and remove it before deserializing the data.

So yeah, it's about controlling (useful) access to that data.

Thanks for answering T.J Crowder. I'm not clear about the need to defeat attempts to deserialize, how does it help in security and what kind of attack it prevents?

@mridkash: The only thing I can think of is that they don't want people using that API via JSON-P, which uses script tags to get around the Same Origin Policy. Also, they apparently only want the result consumed by someone who knows about the for loop, since of course that will break any standard JSON decoder (and in a really mean way if the decoder relies on eval). So that API is useless except when retrieved via ajax, and by someone who knows to remove that preface. Perhaps it's meant to only be used by their client-side code and they change the marker periodically...

@mridkash: Yeah, but remember it only controls misuse of the data via a web browser. Anyone who wants to can get the data manually, or use a non-browser-based tool to retrieve the text and use it in an automated process (even create a reflector that strips off the prefix). So it's not like it's really secure, just making it awkward for people. And a reflector would eventually show up in your logs as a conspicuously active client. :-)

Why not use /* as the prefix?

@Crowder: In older browsers one can override the Array() function in ways that allow you to catch the data that is passed. This means that you can't always assume that JSON literals evaluated in script tags don't leak.

What does a Ajax call response like 'for (;;); { json data }' mean? - ...

ajax json facebook
Rectangle 27 1

The ugly contraption below is able to do (roughly) what you want. Feed you json source string as parameter to DeserializeToDataTable and collect the result datatable. It worked on your sample. I can't guarantee it will work in the rest of your data. The purpose here is to provide a working start kit which you can study, understand, debug and adapt to suit your needs.

Private Function DeserializeToDataTable(ByVal jsource As String)
    Dim JRootObject = JObject.Parse(jsource)
    Dim Children = JRootObject.SelectTokens("$..data.*").ToArray
    Dim Records = Children.OfType(Of JObject).ToArray
    Dim dicList As New List(Of Dictionary(Of String, Object))
    For Each rec In Records
        dicList.Add(DeserializeToDictionary(rec))
    Next
    Dim fieldnames = dicList.SelectMany(Function(d) d.Keys).Distinct.ToArray
    Dim dt As New DataTable
    For Each fieldname In fieldnames
        dt.Columns.Add(fieldname, GetType(Object))
    Next
    Dim row As DataRow
    For Each dic In dicList
        row = dt.NewRow
        For Each kvp In dic
            row.SetField(kvp.Key, kvp.Value)
        Next
        dt.Rows.Add(row)
    Next
    Return dt
End Function

Private Function DeserializeToDictionary(ByVal json_object As JObject) As Dictionary(Of String, Object)
    Dim dic = New Dictionary(Of String, Object)
    For Each field In json_object.Properties
        Select Case field.Value.Type
            Case JTokenType.Array
                Dim subobject = New JObject
                Dim item = 0
                For Each token In field.Value
                    subobject("item" & item) = token
                    item += 1
                Next
                Dim subdic = DeserializeToDictionary(subobject)
                For Each kvp In subdic
                    dic(kvp.Key) = kvp.Value
                Next
            Case JTokenType.Boolean
                dic(field.Name) = field.Value.ToObject(Of Boolean)
            Case JTokenType.Bytes
                dic(field.Name) = field.Value.ToObject(Of Byte())
            Case JTokenType.Date
                dic(field.Name) = field.Value.ToObject(Of Date)
            Case JTokenType.Float
                dic(field.Name) = field.Value.ToObject(Of Double)
            Case JTokenType.Guid
                dic(field.Name) = field.Value.ToObject(Of Guid)
            Case JTokenType.Integer
                dic(field.Name) = field.Value.ToObject(Of Integer)
            Case JTokenType.Object
                Dim subdic = DeserializeToDictionary(field.Value)
                For Each kvp In subdic
                    dic(kvp.Key) = kvp.Value
                Next
            Case JTokenType.String
                Try
                    dic(field.Name) = field.Value.ToObject(Of String)
                Catch ex As Exception
                    dic(field.Name) = field.Value.ToObject(Of Object)
                End Try
            Case JTokenType.TimeSpan
                dic(field.Name) = field.Value.ToObject(Of TimeSpan)
            Case Else
                dic(field.Name) = field.Value.ToString
        End Select
    Next
    Return dic
End Function

You must be aware of this when using code above:

  • It uses recursion to flatten a multi-branch structure. So, { "A":"aaaa", "B":"bbbb", "C":{ "D":"dddd", "E":"eeee", "F":"ffff" } } } will become A |B |D |E |F ----+----+----+----+---- aaaa|bbbb|dddd|eeee|ffff

The way I did assumes there won't be duplications when flattening; should there be those, it will preserve just the last. So,

{
    "A":"aaaa",
    "B":"bbbb",
    "C":{
            "D":"d1d1",
            "E":"e1e1",
            "F":"f1f1"
        },
    "G":{
            "D":"d2d2",
            "E":"e2e2",
            "F":"f2f2"
        }
    }
}
A   |B   |D   |E   |F
----+----+----+----+----
aaaa|bbbb|d2d2|e2e2|f2f2
JsonPath

It uses JsonPath once at the beginning. Your sample, however, made me think simple iterations could make it from the point we have a collection of record-like objects. Please keep in mind the limitations of my code, though. There's plenty of room for improvement.

Right, but it got me on the right track. The subsequent deserialize to dictionary was the real trick. Because I hate myself, I'm also playing around with trying to post to these servers, leading to this question if you have a moment.

c# - Efficient deserializing of dynamic JSON data into datatable - Sta...

c# json vb.net serialization json.net
Rectangle 27 8

It sounds like you are not creating distinct layers in your application. If your main form has 1,000 lines of code, you are probably putting business logic or even data access code in the form itself. You really need to separate out your layers (at least presentation layer, business logic layer, and data access layer). This will help you better follow good OO principles. In relation to VB.NET specifically, here are a few articles that might help:

These will help you with layers and how to implement them in VB.NET. The ASP.NET article will work fine because the actual ASP.NET is the Presentation Layer, which you would replace with Winforms.

If you want to watch videos on OO design principles, here is a good site to do so (it isn't free but it is very cheap):

Yeah, as the code in my main form got longer I knew I was doing something wrong. Thanks, I'll take a look at the links

+1 for the Head First and tier references... :-)

@Johan - yeah, good call. Basically, you want to think about the future. If you decide to move to WPF, will you break your entire application? If you decide to change from a SQL backend (for example) to an XML backend, would it break your entire application? You want these types of changes to have as limited an impact on your application as possible. That way, when the boss decides that new tech is the way to go, you aren't re-inventing the wheel by redoing the 1,000+ lines of code.

VB.NET best practices and designing classes - Stack Overflow

vb.net
Rectangle 27 103

JSON is similar to other data formats like XML - if you need to transmit more data, you just send more data. There's no inherent size limitation to the JSON request. Any limitation would be set by the server parsing the request. (For instance, ASP.NET has the "MaxJsonLength" property of the serializer.)

so technicly, If I wanted to take the WHOLE sourcecode to this whole page, it could be sent as a json object?

Yes, with proper encoding.

It may be worth noting that the "default is 2097152 characters, which is equivalent to 4 MB of Unicode string data" for the property JavaScriptSerializer.MaxJsonLength mentioned in Amber's answer. (N.B. I have quoted from MSDN)

@AsadHasan A server can parse or serialize, depending on which direction the data is going.

Is there a limit on how much JSON can hold? - Stack Overflow

json