question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we have support to Json.net?

See original GitHub issue

That sounds dumb, but I have the models from my Backend different than my Frontend, so I have a middle layer to treat things like this. I want to implement typewriter, but does it support Json.net? I have the Model in C# like:

` public class myModel
    {
    [JsonProperty(PropertyName = "id")]
    public int id { get; set; }

    [JsonProperty(PropertyName = "description")]
    public string description { get; set;
    }
    [JsonProperty(PropertyName = "startDate")]
    public string start_date { get; set; }

    [JsonProperty(PropertyName = "endDate")]
    public string end_date { get; set; }

    [JsonProperty(PropertyName = "val")]
    public float p_value { get; set; }
    }`

And I want the result inside the Typescript as:

    export class myModel{
        
        // ID
        public id: number = 0;
        // DESCRIPTION
        public description: string = null;
        // STARTDATE
        public startDate: string = null;
        // ENDDATE
        public endDate: string = null;
        // VAL
        public val: number = 0;
    }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
guifelipercommented, Oct 17, 2017

Yes, I’m using the properties as start_date, because the backEnd uses like that, but the frontEnd is in camelCase.

Thank you, I’m going to read the documentation

1reaction
Sc0tTyXLcommented, Oct 17, 2017

Is there a reason you are naming the properties start_date and not StartDate?

You could then just use: Json.NET’s CamelCasePropertyNamesContractResolver and remove the json property declarations: https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Serialization_CamelCasePropertyNamesContractResolver.htm

Read more comments on GitHub >

github_iconTop Results From Across the Web

Json.NET - Newtonsoft
If you need it, Json.NET supports converting between XML and JSON. Open Source. Json.NET is open source software and is completely free for...
Read more >
Migrate from Newtonsoft.Json to System.Text.Json - .NET
Learn about the differences between Newtonsoft.Json and System.Text.Json and how to migrate to System.Text.Json.
Read more >
Newtonsoft.Json vs System.Text.Json vs Json.Net : r/csharp
Json will handle it better. Upvote 11
Read more >
Does .NET 4 have a built-in JSON serializer/deserializer?
JSON.Net is well supported and it appears that Microsoft intend to adopt it themselves "We on the web team will be including JSON.NET...
Read more >
Despite .NET Core 3 Deprecation, Newtonsoft JSON ...
Despite being deprecated by Microsoft in .NET Core 3.0, the wildly popular Newtonsoft.Json JSON serializer still rules the roost in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found