json.net

Json structure is returned empty, without property names and values when using Newtonsoft JsonConvert in FB C# client

妖精的绣舞 提交于 2019-12-13 17:22:23
问题 I'm working on asp.net mvc 4 application which uses Facebook C# SDK (6.0.10.0) and Newtonsoft.Json (4.5.0.0). Request with FacebookClient returns expando object: [Authorize] public ActionResult GetFbData(string path = "me"){ var expando = this.fb.Get(path); return Json(expando); } Returned Json looks like: [{"Key":"id","Value":"100000xxxxxxxx"},{"Key":"name","Value":"John Doe"} ... ] I want to return it in format {id:100000xxxxxxx, name:"John Doe", ... } so I added this to the code which

Json.NET doesn't work with Mono under Debian

依然范特西╮ 提交于 2019-12-13 17:04:12
问题 i'm making an application with C# and Mono framework (to make it compatible on Linux). In this app i'm using also using the Json.NET library, but seems to not work with Mono because every time i try to start the application i get this error: Missing method .ctor in assembly /root/igloo/Newtonsoft.Json.dll, type System.Runtime.CompilerServices.ExtensionAttribute Can't find custom attr constructor image: /root/igloo/Newtonsoft.Json.dll mtoken: 0x0a000077 [20/03/14 06:11:50] System

JSON .NET deserialize into complex type with object key/name

旧街凉风 提交于 2019-12-13 16:43:27
问题 I'm using Newtonsoft JSON .NET in my project for most of my API/JSON usage, and usually deserialize or convert into a complex type for easier usage. The problem is that I can't seem to figure out a good way to handle an object with a name/key that is dynamic (ie it is different every time). The JSON I need to parse isn't exactly made to standard, but currently it's not in my power to change it. The relevant JSON is below (I didn't include the whole structure). "orders": { "32f5c31d-a851-40cf

Deserializing JSON to a .net base class with JSON.net

痞子三分冷 提交于 2019-12-13 16:14:58
问题 I am trying to deserialize GeoJSON using the JSON.net library. The geometry component of each feature can be of many different types based on the "type" attribute value. I need to deserialize the geometry component of this GeoJSON into a geometry object model like so: public abstract class Geometry { ... } public class Point : Geometry { ... } public class LineString : Geometry { ... } public class Polygon : Geometry { ... } So based on the value of the "type" attribute, it will deserialize

Using JSON.NET and C# reading file and deserialize the JSON fails

你。 提交于 2019-12-13 16:09:29
问题 I have a JSON file named 'movies.json' which contains an object and an array of 3 movies. The JSON in movies.json looks like this: { "theMovies": [ { "name": "Starship Troopers", "year": 1997 }, { "name": "Ace Ventura: When Nature Calls", "year": 1995 }, { "name": "Big", "year": 1988 } ] } I also have a class named Movie public class Movie { public string Name { get; set; } public int Year { get; set; } } I am trying to read the file into a string and deserialize the JSON to a type of Movie

Parse huge OData JSON by streaming certain sections of the json to avoid LOH

只谈情不闲聊 提交于 2019-12-13 15:15:56
问题 I have an OData response as JSON ( Which is in few MBs ) and the requirement is to stream "certain parts of JSON" without even loading them to memory. For Example : When I'm reading the property " value[0].Body.Content " in the below JSON (which will be in MBs), I want to Stream this value part without de-serializing it into an Object of type string. So basically read the value part into a fixed size byte array and write that byte array to destination stream (repeating the step until that

StringEnumConverter invalid int values

两盒软妹~` 提交于 2019-12-13 14:25:09
问题 I have a simple Controller with a POST method. My model has a property of type enum. When I send valid values ,everything works as expected { "MyProperty": "Option2"} or { "MyProperty": 2} If I send an invalid string { "MyProperty": "Option15"} it correctly gets the default value (Option1) but if I send an invalid int ,it keep the invalid value { "MyProperty": 15} Can I avoid that and get the default value or throw an error? Thanks public class ValuesController : ApiController { [HttpPost]

Cannot Deserialize the Current JSON Object (Empty Array)

 ̄綄美尐妖づ 提交于 2019-12-13 14:16:19
问题 I am trying to make this program that formats all these objects into a treeview, to do this (I'm using JSON for ordering the objects), I needed to parse the JSON, so I chose JSON.NET. So here is an example of how the formatting is: { "Space": { "ClassName": "SpaceObject", "Name": "Space", "Children": { "Object1": { "ClassName": "Object", "Name": "Object1", "Children": [] }, "Object2": { "ClassName": "Object", "Name": "Object2", "Children": [] } } } } public class CObject { [JsonProperty

Deserializing json string into an object - Silverlight

非 Y 不嫁゛ 提交于 2019-12-13 13:42:51
问题 I've spent a good while this afternoon trying to implement the deserialization of JSON within a string, at first I was using DataContractJsonSerializer as my environment is Silverlight however it does not appear to support using a Dictionary out of the box (Raised in many other SO questions). As an alternative I decided to use JSON.NET for the time being (Based on the answers to the aforementioned SO questions) and i've hit the following problem. I want to deserialize the JSON below: {

Parsing JSON on Windows Phone 7

谁说我不能喝 提交于 2019-12-13 13:06:28
问题 I'm trying to do some simple JSON manipulation on the Windows Phone 7. JSON.NET looks great, but VS2010 complains when I try to add a reference to it. It let me add the Silverlight dll, but warned me that it could result in weird app behavior, so I'm skeptical that it would actually work. This looks like a fine way to serialize and deserialize data, but I need to actually query it. Could I just use this technique to serialize it to a IQueryable , then use LINQ on it? Can I somehow convert the