json-deserialization

Unable to cast object of type Newtonsoft.Json.Linq.JObject even though I am trying to cast to an object with matching properties

人走茶凉 提交于 2019-12-29 09:56:30
问题 I am working with ASP.NET Core 2.0 in VS2017. I am trying to deserialize some JSON that is returned in an HttpResponseMessage but I am getting an "Unable to cast object of type..." exception. Here is the code that is failing; FilesUploadedListResponse fileUploadListResponse = new FilesUploadedListResponse(); string jsonResult = response.Content.ReadAsStringAsync().Result; fileUploadListResponse = (FilesUploadedListResponse)JsonConvert.DeserializeObject(jsonResult); The last line is where I

How to Deserialize a Json Array with C#?

不问归期 提交于 2019-12-27 06:16:16
问题 I use RestSharp to make a Rest API Call. public class GetValues { public string Values{ get; set; } } public class JsonObjects { public List<GetValues> Values{ get; set; } } RestRequest restRequest = new RestRequest("api/tempCatalog/temp1", Method.GET); restRequest.AddHeader("Accept", "application/json"); restRequest.AddHeader("Content-Type", "application/json"); restRequest.AddHeader("Authorization", token); IRestResponse restResponse = clientRest.Execute(restRequest ); string Content =

How to Deserialize a Json Array with C#?

余生长醉 提交于 2019-12-27 06:14:04
问题 I use RestSharp to make a Rest API Call. public class GetValues { public string Values{ get; set; } } public class JsonObjects { public List<GetValues> Values{ get; set; } } RestRequest restRequest = new RestRequest("api/tempCatalog/temp1", Method.GET); restRequest.AddHeader("Accept", "application/json"); restRequest.AddHeader("Content-Type", "application/json"); restRequest.AddHeader("Authorization", token); IRestResponse restResponse = clientRest.Execute(restRequest ); string Content =

How to deserialize jsonconvert newtonsoft?

丶灬走出姿态 提交于 2019-12-25 18:23:48
问题 Hello guys Could you help me? I have the class below public class EmpTraining { public int CodColig { get; set; } public string EmpID { get; set; } public string Employee { get; set; } public string CostCenter { get; set; } public string Department { get; set; } public string WorkstationID { get; set; } public string Workstation { get; set; } public string Training { get; set; } public string CreateDt { get; set; } public string DueDt { get; set; } } And I need to deserialize the json below.

Deserialize JSON to string in raw format using Jackson

夙愿已清 提交于 2019-12-25 08:59:26
问题 I have a use case where I want the JSON to be converted to string as it is, but it is failing and giving me null, here is my POJO: @Data @JsonSnakeCase @JsonIgnoreProperties(ignoreUnknown = true) public class DocumentTemplateRequest { @Enumerated(EnumType.STRING) private TemplateState state; @JsonDeserialize(using = JsonAsStringDeserializer.class) private String inputSchema; } the Json I am using as payload: { "state": "staging", "input_schema": { "title": "Person", "type": "object",

Deserializing Import Io JSON with multiple objects

萝らか妹 提交于 2019-12-25 04:35:13
问题 Morning all, Im using Newtonsoft.JSON to deserialize a JSON response from Import Io. I have successfully used http://json2csharp.com/ to build a data model successfully in one instance to gain access to the data, however in that instance only one JSON object was returned. I am now working on a new piece of JSON that is being returned with multiple objects and i'm hitting issues with the following error message: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON

Why JsonConverter.WriteJson() never gets called, although JsonConverter.ReadJson() does get called?

不羁的心 提交于 2019-12-25 04:09:27
问题 Why my custom JsonConverter.WriteJson() method doesn't get called ? class MyType{ [JsonConverter(typeof(DocumentXamlDeserializer))] public string GuiData { get; set; } public string SimpleString; } Although the ReadJson does get called: public class DocumentXamlDeserializer : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { writer.WriteValue(Gui.Handler.SerializeData()); } public override object ReadJson(JsonReader reader, Type

Convert JSon to dynamic object in VB.Net

为君一笑 提交于 2019-12-25 03:06:26
问题 I am using VB.Net and calling salesforce API. It returns very ugly JSON which I am not able to deserialize. I have a following code using JSON.Net Dim objDescription As Object = JsonConvert.DeserializeObject(Of Object)(result) objDescription contains many properties, one on=f them in fields . But when I write something like objDescription.fields it gives me error. objDescription.fields Public member 'fields' on type 'JObject' not found. Object I am not very sure but I think it C# allow to

How to read JSON and Display in html table in c#?

∥☆過路亽.° 提交于 2019-12-25 02:58:57
问题 I have following JSON : {"ios_info":{"serialNumber":"F2LLMBNJFFFQ1","imeiNumber":"0138840041323551","meid":"","iccID":"89014104276400960452","firstUnbrickDate":"11\/27\/13","lastUnbrickDate":"11\/27\/13","unbricked":"true","unlocked":"false","productVersion":"7.1.2","initialActivationPolicyID":"23","initialActivationPolicyDetails":"US AT&T Puerto Rico and US Virgin Islands Activation Policy","appliedActivationPolicyID":"23","appliedActivationDetails":"US AT&T Puerto Rico and US Virgin Islands

Deserialize JSON to C# Objects with Childs

瘦欲@ 提交于 2019-12-25 01:34:26
问题 I have a JSON string and I need some help to deserialize it. At the moment my result is always null. var results = JsonConvert.DeserializeObject<Root>(json); // result == null My JSON: {"First":{"FirstData1":{"date":"2018-01-01","hint":""}, "FirstData2":{"date":"2018-01-06","hint":""}}, "Second":{"SecondData1":{"date":"2018-01-01","hint":""}, "SecondData2":{"date":"2018-01-06","hint":""}}}.... Only on the last Node there is actual property naming... MyObjects public class Root { public