json.net

Return JsonResult from web api without its properties

这一生的挚爱 提交于 2019-12-20 09:01:26
问题 I have a Web API controller and from there I'm returning an object as JSON from an action. I'm doing that like this: public ActionResult GetAllNotificationSettings() { var result = new List<ListItems>(); // Filling the list with data here... // Then I return the list return new JsonResult { Data = result }; } But this way the JsonResult object including its Data attribute is serialized as JSON. So my final JSON that is return by the action looks like this: { "ContentEncoding": null,

Taking JSON output into table format

我与影子孤独终老i 提交于 2019-12-20 07:39:37
问题 I am trying to take the values I have parsed from a JSON file and convert them into rows. I have tried all week, but still cannot figure this out. My current output looks like this: a: 1 b: 2 c: 3 a: 1a b: 2a c: 3a a: 1b b: 2b c: 3b I want my output to be like this, but I cannot find a solution. a b c 1 2 3 1a 2a 3a 1b 2g 3b using System; using Newtonsoft.Json; using System.Collections.Generic; public class Program { public static void Main() { string json = @"{ 'somethingone': 'abc',

Output a JSON property name with a dash using an anonymous object

回眸只為那壹抹淺笑 提交于 2019-12-20 07:18:17
问题 I am using a third party API which is like this below. It uses Json serializer to output public Output(string name, object value); I have to place the following json string in my output file from C# Output("somename", new {my-name : "somevalue"}) The issue is C# does not allow identifiers with dash (-). How do I achieve this ? Tried putting raw value like below but it adds back slash (\) to the file output which is not going very well. Output("somename", @"{""my-name"":""somevalue""}") Any

Moving to JSON.NET 4.0.3 broke my app

匆匆过客 提交于 2019-12-20 06:57:33
问题 I have a Windows Phone 7.1 (Mango) application that was using JSON.NET 4.0.2. I upgraded it to 4.0.3 and now I get all kinds of error. A deserialized class that was working before is now throwing this error : Could not load type 'System.Dynamic.IDynamicMetaObjectProvider' from assembly 'System.Core, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'. I also make use of the Linq feature by using JArray and now I get this message: {"Could not load type 'Newtonsoft.Json.Linq

Moving to JSON.NET 4.0.3 broke my app

旧时模样 提交于 2019-12-20 06:56:18
问题 I have a Windows Phone 7.1 (Mango) application that was using JSON.NET 4.0.2. I upgraded it to 4.0.3 and now I get all kinds of error. A deserialized class that was working before is now throwing this error : Could not load type 'System.Dynamic.IDynamicMetaObjectProvider' from assembly 'System.Core, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'. I also make use of the Linq feature by using JArray and now I get this message: {"Could not load type 'Newtonsoft.Json.Linq

Moving to JSON.NET 4.0.3 broke my app

对着背影说爱祢 提交于 2019-12-20 06:56:08
问题 I have a Windows Phone 7.1 (Mango) application that was using JSON.NET 4.0.2. I upgraded it to 4.0.3 and now I get all kinds of error. A deserialized class that was working before is now throwing this error : Could not load type 'System.Dynamic.IDynamicMetaObjectProvider' from assembly 'System.Core, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'. I also make use of the Linq feature by using JArray and now I get this message: {"Could not load type 'Newtonsoft.Json.Linq

how to de-serialize JSON data in which Timestamp it-self contains fields?

◇◆丶佛笑我妖孽 提交于 2019-12-20 06:39:47
问题 I am Unable to map the class with the given JSON data: { "Meta Data": { "1. Information": "Intraday (15min) open, high, low, close prices and volume", "2. Symbol": "MSFT", "3. Last Refreshed": "2018-09-28 15:45:00", "4. Interval": "15min", "5. Output Size": "Full size", "6. Time Zone": "US/Eastern" }, "Time Series (15min)": { "2018-09-28 15:45:00": { "1. open": "114.2800", "2. high": "114.5600", "3. low": "114.2400", "4. close": "114.4800", "5. volume": "2316251" }, "2018-09-28 15:30:00": {

Newtonsoft.Json.JsonReaderException

回眸只為那壹抹淺笑 提交于 2019-12-20 06:19:33
问题 I have a problem with Newtonsoft.Json. I'm trying to parse JSON from a URL but I'm getting an error. Here is the JSON: [ { "ID": "0", "Nome": "we", "Data": "2013-09-16", "Orario": "00:00:16", "Prestazione": "dfg", "Stato": "dfg", "Numero_Telefono": "dfg" }, { "ID": "0", "Nome": "fg", "Data": "2013-09-26", "Orario": "00:00:00", "Prestazione": "", "Stato": "", "Numero_Telefono": "" }, { "ID": "1", "Nome": "davide", "Data": "2013-09-26", "Orario": "00:00:16", "Prestazione": "ds", "Stato": "sd",

Issues parsing a 1GB json file using JSON.NET

孤街浪徒 提交于 2019-12-20 06:05:50
问题 I have gotten an application where the input has been scaled up from 50K location records to 1.1 Million location records. This has caused serious issues as the entire file was previously de-serialized into a single object. The size of the object is ~1GB for a production like file with 1.1 Million records. Due to large object GC issues I want to keep the de-serialized object below the 85K mark. I'm trying to parse out a single location object at a time and de-serialize it so I can control the

Unexpected character encountered while parsing value: j. Path '', line 0, position 0

那年仲夏 提交于 2019-12-20 05:50:58
问题 t fails to deserialize/prase this json, ive tried multiple combinations with different methods to try and make this work but nothing seems to do it... The code im using WebClient wc = new WebClient(); var json = (JObject)JsonConvert.DeserializeObject(wc.DownloadString("http://services.runescape.com/m=website-data/playerDetails.ws?names=[%22" + Username.Replace(" ", "%20") + "%22]&callback=jQuery000000000000000_0000000000&_=0")); the json its trying to deserialize... jQuery000000000000000