json.net

Serialize Custom Attribute Values

不想你离开。 提交于 2019-12-11 06:55:23
问题 Given the following class: public class PayrollReport { [UiGridColumn(Name = "fullName",Visible = false,Width = "90")] public string FullName { get; set; } [UiGridColumn(Name = "weekStart", CellFilter = "date")] public DateTime WeekStart { get; set; } } And this custom attribute [AttributeUsage(AttributeTargets.All)] public class UiGridColumn : Attribute { public string CellFilter { get; set; } public string DisplayName { get; set; } public string Name { get; set; } public bool Visible { get;

Serialize and deserialize custom type using Newtonsoft.Json without attributes

試著忘記壹切 提交于 2019-12-11 06:53:10
问题 I know that there are JsonConverters that I can use for custom serialization/deserialization. But I do not want to apply this via attributes, rather via code. My framework has plugin support for serializers and I'm about to add Newtonsoft JSON support now. And thus, I do not want to add attributes specific for newtonsoft to my types. Is there any way to apply a JsonConverter to a specific type in any other way? I would like to do something along the lines of: serializer.AddTypeHandler(typeof

JSON parsing object to string - preserve order of elements

岁酱吖の 提交于 2019-12-11 06:45:45
问题 I have this class that needs to be serialized to json: [DataContract] public class InfoRequest { [DataMember] public string folder_id { get; set; } [DataMember] public string file_type_id { get; set; } [DataMember] public string prefix { get; set; } [DataMember] public fileInfo[] files; [DataMember] public termInfo[] terms; } [DataContract] public class fileInfo { [DataMember] public string name { get; set; } [DataMember] public string size { get; set; } } [DataContract] public class termInfo

Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' in Azure Functions

不打扰是莪最后的温柔 提交于 2019-12-11 06:45:40
问题 I am refering a C# library project from my Azure Function (Service bus queue trigger). The library is referencing the Newtonsoft nuget version 10.0.1. While running the function locally on my visual studio, it gives this error . {"Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.":"Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken

Newtonsoft deserialize object that extends from Collection<Item>

限于喜欢 提交于 2019-12-11 06:34:18
问题 I'm trying to use NewtonSoft.Json deserializer, but I don't know if what I'm trying to do is doable, cuase every example of collections that I've seen are like this: public class ItemRecords { public List<ItemRecords> Items { get; set; } ... } And what I want is something that looks like as it's explained below... I have this two classes: public class ItemRecords : Collection<ItemRecord> { [JsonProperty("property1")] public int Property1 { get; set; } [JsonProperty("property2")] public int

Assembly looking for wrong version of Newtonsoft.Json.dll

安稳与你 提交于 2019-12-11 06:26:27
问题 My project is using Newtonsoft.Json.dll. I have added the dll as a reference to my project and im using version 8.0.2 Everything works on my pc however when i transfer everything to a new pc along with Newtonsoft.Json.dll i get the error Could not load file or assembly 'Newtonsoft.Json‚ Version=4.0.3.0‚ Culture=neutral‚ PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. Im not referencing that version anywhere and there is nothing in my app

How can I deserialize an ADO.NET DataTable that contains null values using Json.NET?

爷,独闯天下 提交于 2019-12-11 06:25:11
问题 I am attempting to use Newtonsoft.Json.Net35 Version 4.0.2.0 to deserialize an ADO.NET DataTable that contains null values. Serialization works fine: [Test] public void SerializeDataTableWithNull() { var table = new DataTable(); table.Columns.Add("item"); table.Columns.Add("price", typeof(double)); table.Rows.Add("shirt", 49.99); table.Rows.Add("pants", 54.99); table.Rows.Add("shoes"); // no price var json = JsonConvert.SerializeObject(table); Assert.AreEqual(@"[" + @"{""item"":""shirt"","

I am trying to deserialize JSON data to a dataset

大憨熊 提交于 2019-12-11 06:22:13
问题 I thought JSON was supposed to be easy to use. I have a C# .NET Windows form program in Visual Studio 2015 being used as a client consuming a Web API 2 remote server with RestSharp as the HTTP client. the data returned from the API call is in Json format. However, when I try to deserialize the returned Json into a dataset using this statement: DataSet data = (DataSet)JsonConvert.DeserializeObject(response.Content, (typeof(DataSet))); , I get this error: "Unexpected JSON token while reading

How to Loop calls to Pagination URL in C# HttpClient to download all Pages from JSON results

一曲冷凌霜 提交于 2019-12-11 06:15:07
问题 My 1st question, so please be kind... :) I'm using the C# HttpClient to invoke Jobs API Endpoint. Here's the endpoint: Jobs API Endpoint (doesn't require key, you can click it) This gives me JSON like so. { "count": 1117, "firstDocument": 1, "lastDocument": 50, "nextUrl": "\/api\/rest\/jobsearch\/v1\/simple.json?areacode=&country=&state=&skill=ruby&city=&text=&ip=&diceid=&page=2", "resultItemList": [ { "detailUrl": "http:\/\/www.dice.com\/job\/result\/90887031\/918715?src=19", "jobTitle": "Sr

How to deserialize this JSON with VB.NET

对着背影说爱祢 提交于 2019-12-11 06:05:51
问题 I have this JSON data: {"asks":[["0.26039995",19.91610429],["0.26063345",3070.562292]],"bids":[["0.26000017",30381.45513902],["0.26000000",8299.1410574]],"isFrozen":"0","seq":50663190} I wrote this code: Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim wc As New WebClient Dim sURL As String = "https://poloniex.com/public?command=returnOrderBook&currencyPair=USDT_STR&depth=" & 2 Dim res As String = wc.DownloadString(New Uri(sURL)) Dim m As IEnumerable(Of