json.net

LINQ to JSON

I am trying the execute the sample code of LINQ to JSON (mentioned below) but it is giving me following error Stack Trace: [InvalidOperationException: Lambda Parameter not in scope] Code I am executing is: JObject rss = new JObject( new JProperty("id", "James Newton-King"), new JPrope...

Using json.net, how would I construct this json string?

Hi, I was weaving my own json programatically, and was adviced to not roll my own as escaping for the forward slash and line breaks won't be enough basically. My json is to look like: {"rc": "200", "m" : "", "o": "<div class='s1'> <div class='avatar'> <a href='\/asdf'>asdf<\/a><br \/> ...

What namespace has JObject in json.net?

What namespace has JObject in json.net? Just installed int and can't seem to find that class? ...

Serialize Entity Framework Object using Json.Net

Hi, How do I serialize entity framework object into JavaScript Object (JSON)? I tried using JSON.NET but I am getting the following exception when I try to serialize it. Exception: Newtonsoft.Json.JsonSerializationException, Message="Self referencing loop" Hitesh ...

How to use jqGrid with C#/ASP.NET and JSON.NET (and no AJAX.NET stuff)?

OK, I've been looking into this a few days and am not particularly sure what I am doing wrong. If anyone has working examples of using jqGrid with C#/ASP.NET and open source tools, please, please let me know where to find them. Any tips on finding decent documentation or tools I could use to debug this would be most appreciated too (I'...

Json.NET serialization pre and post calls

Hi, I am using Json.NET to serialize an object graph. For each object that is serialized or deserialized, I want to call a method on that object before the serialization takes place. For e.g. all my objects implement an interface INotified with a method OnSerializing. I want OnSerializing to be called before the object is serialized. I...

JSON.net returning malformed JSON

Hey, I am using json.net to parse objects and delivering them to a webservice I have made. The objects are LINQ-objects. When I access this webservice with JQuery, it doesn't parse the JSON correctly. There seems to be something wrong with the formatting.. The JSON-string I get is this one: [{"typeid":1, "typename":"binders", "des...

Serializing LINQ-objects to JSON-strings - HUGE strings

Hey, I am using LINQ to access my database, and thereby gets a LINQ-created object which I want to send to the browser (this is a webservice) as a JSON-object. This works well by now, but when I add some testdata to the database (about 10-20 entries in each table) this fails miserably. The reason is that the LINQ-object contains all the...

Passing complex JSON string to 1 parameter webmethod in c# - desearialize into object (json.net)?

I have been happy serializing with javascript objects into JSON using JSON.stringify And sending along to my "static" webmethod in c#/asp.net and sure enought it arrives .. I need the correct number of parameters hence if my json object has "startDate","endDate","reserve" then my webmethod needs these as parameters. "Basica...

How to pass XML as POST to an ActionResult in ASP MVC .NET

Hi, I am trying to provide a simple RESTful API to my ASP MVC project. I will not have control of the clients of this API, they will be passing an XML via a POST method that will contain the information needed to perform some actions on the server side and provide back an XML with the result of the action. I don't have problems sendin...

JSON.NET with GridView

Hi, I am trying to find a way bind Grid view to a JSON.NET parsed Linq to Json object simply am calling JObject yrs = SearchData(""); then use one property to be bound to Grid view GridView1.DataSource = yrs["businesses"].Children(); I cant find any resources for something like that neither binding directly work nor using Children...

How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?

I have a simple key/value list in JSON being sent back to ASP.NET via POST. Example: { "key1": "value1", "key2": "value2"} I AM NOT TRYING TO DESERIALIZE INTO STRONGLY-TYPED .NET OBJECTS I simply need a plain old Dictionary(Of String, String), or some equivalent (hash table, Dictionary(Of String, Object), old-school StringDictionary-...

can json.net handle a List<object>?

Hi, List<User> list = LoadUsers(); JObject json = new JObject(); json["users"] = new JValue(list); Doesn't seem to be working? Error: oculd not determin JSON object type for type System.Collections.Generic.List ...

Parse JSON in C#

I'm trying to parse some JSON data from the Google AJAX Search API. I have this URL and I'd like to break it down so that the results are displayed. I've currently written this code, but I'm pretty lost in regards of what to do next, although there are a number of examples out there with simplified JSON strings. Being new to C# and .NET...

json string for null object?

I tried to use JSon.Net library to serialize objec to a JSon string. If the object is null, the method does not throw exception with "null" returned. Should this be something like "{T: null}"? T instance = default(T); // null for example ///... string jString = JsonConvert.SerializeObject(instance); // null back // should it be "{T:...

Deserializing variable Type JSON array using DataContractJsonSerializer

I have a JSON string in this form: string jsonStr = "[\"A\", [\"Martini\", \"alovell\"],[\"Martin\", \"lovell\"]]" I am trying to deserialize the JSON using the C# .NET deserializer DataContractJsonSerializer with the following code snippet MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr)); DataContractJsonSerializ...

Suggestions on how to create a custom GeoJson serializer using JSON.NET?

I will be attempting to create a C# library to serialize objects to GeoJSON using Json.NET ( for serialization ) and GeoAPI.NET ( for geometry definitions ). I have thought about two different approaches for the serialization implementation and I am not clear which one would be the best approach. They are: Approach 1 - Custom Attrib...

How to pass a JSON date value via ASP.NET MVC?

ASP.NET Json() formats and returns a date as {"d":"\/Date(1240718400000)\/"} which has to be dealt w/ on the client side which is problematic. What are your suggestions for approaches to sending date values back and forth? Thanks ...

ajax request that returns json array, IE6/7 is caching it and data is not fresh

Hi, for some reason, IE6/7 is caching the ajax call that returns a json result set back. My page makes the call, and returns a json result which I then inject into the page. How can I force IE6/7 to make this call and not use a cached return value? ...

Asp.net MVC json or Json.net?

Hi I am now using asp.net mvc and wondering what is a better choice using the built in Json or Json.Net I am not sure if one has an advantage over another. Also if I do choose to go down the route of Json.Net then should I go with the stable version or beta 4? I am not sure how unstable the betas are. ...