Equivalent of [JsonPropertyName] from C# in TypeScript

Advertisements I need to deserialize some JSON response to my class defined in Angular. Let’s give example class: export class ChatHubInfo { hubUrl: string = undefined! accessToken: string = undefined! } But the JSON response looks like: { "hub_url": "https://localhost:8080/", "access_token": "v4.public.eY…" } So while deserializing I want to map hub_url to hubUrl and so… Read More Equivalent of [JsonPropertyName] from C# in TypeScript

Getting error: Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'myclass'

Advertisements I am trying to deserialize a javascript kind of JSON "{\n \"resultSet1\": [\n {\n \"AgentID\": 13173,\n \"FirstName\": \"Drilon\",\n \"SG_ID\": 14336,\n \"LoginName\": \"UI813926\",\n \"SG_Description\": \"LKC Bauhotline\",\n \"SG_Name\": \"Y_BAU__FO\",\n \"EnterpriseName\": \"LKC_Abdullahu_Drilon\",\n \"LastName\": \"Abdullahu\"\n },\n {\n \"AgentID\": 14432,\n \"FirstName\": \"Pinar\",\n \"SG_ID\": 14336,\n \"LoginName\": \"UI938008\",\n \"SG_Description\": \"LKC Bauhotline\",\n \"SG_Name\": \"Y_BAU__FO\",\n \"EnterpriseName\": \"LKC_Ali_Pinar\",\n \"LastName\": \"Ali\"\n }, ]\n}" Agents and… Read More Getting error: Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'myclass'

Deserialize nested JSON into C# Object

Advertisements I am getting the following response from an API "results": { "wan1": { "id": "wan1", "name": "wan1", "alias": "", "mac": "00:00:00:00:00:00", "ip": "102.165.223.199", "mask": 24, "link": true, "speed": 1000.0, "duplex": 1, "tx_packets": 501850173, "rx_packets": 307154377, "tx_bytes": 442319826490, "rx_bytes": 234140958061, "tx_errors": 0, "rx_errors": 0 }, "dmz": { "id": "dmz", "name": "dmz", "alias": "", "mac": "00:00:00:00:00:00",… Read More Deserialize nested JSON into C# Object

I want to Deserialize the Json-File and output it's data

Advertisements I thought I would understand Json.NET now a bit but unfortunately not. Can somebody help me with that I am trying to show data from the json-file in the Console (Error:CS1061 | List has no definition for "title" | file:Programm.cs | line: 23) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using… Read More I want to Deserialize the Json-File and output it's data

'r' is invalid after a value. Expected either ',', '}', or ']'

Advertisements I am trying to Deserialize string to class with this structure: // this is my json { "MethodName":"PRC_SET_COMMISSION_STATIC", "Input":"{"reqType":"U","sapId":17000100,"offerType":5,"commissionRate":4,"accountNo":null,"fromDate":"2022-05-29T00:00:00","toDate":"2029-05-29T00:00:00","userId":"13601360"}"} And this is my class which I want to get this values: public class ProcessRequestRequestModelCl :AuthenticationModelCl { public string MethodName { get; set; } public string Input { get; set; } } So what I… Read More 'r' is invalid after a value. Expected either ',', '}', or ']'

Exception occurs while deserialize json containing date with different format C#

Advertisements Having json string containing date field { "totalSize": 2, "records": [ { "Id": "5006C000008ZhEDQA0", "CreatedDate": "2021-12-01T15:14:20.000+0000", "CaseNumber": "01378682", "Status": "Open" }, { "Id": "5006C000008ZhE00A0", "CreatedDate": "2021-12-05T08:00:00.000+0000", "CaseNumber": "01378692", "Status": "Open" } ] } I’m trying to do normal Deserialization where CreatedDate datatype is DateTime. JsonSerializer.Deserialize<SFHistoryResponse>(stringResponse); I’m getting The JSON value could not be converted… Read More Exception occurs while deserialize json containing date with different format C#

WinForms Error Cannot deserialize the current JSON array (e.g. [1,2,3]) into type

Advertisements i have a code like this: Dictionary<string, Diskop> data = JsonConvert.DeserializeObject<Dictionary<string, Diskop>>(res.Body.ToString()); and this is the Diskop class: internal class Diskop : Dictionary<string, Diskop> { public string isim { get; set; } public int no { get; set; } public int puan { get; set; } } and i get that error: Newtonsoft.Json.JsonSerializationException: ‘Cannot… Read More WinForms Error Cannot deserialize the current JSON array (e.g. [1,2,3]) into type