Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer adding JsonProperty attributes #16

Closed
PTAdvanced opened this issue Oct 6, 2020 · 1 comment
Closed

No longer adding JsonProperty attributes #16

PTAdvanced opened this issue Oct 6, 2020 · 1 comment

Comments

@PTAdvanced
Copy link

Hi

I noticed when using the tool today from this URL https://json2csharp.com/json-to-csharp that the JsonPropertyAttributes are no longer being added to the output C# Code.

This was working yesterday. I noticed that a PR/13 branch was merged in yesterday.

So with this example JSON

{						
   "Class1":{	
      "id":4,
      "user_id":"user_id_value",
      "created_at":"2015-06-02 23:33:90",
      "updated_at":"2015-06-02 23:33:90"
	 }
}

I would expect to see this response:

// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse); 
    public class Class1    {
	  	[JsonProperty("id")]
        public int Id { get; set; } 

		[JsonProperty("user_id")]
        public string UserId { get; set; } 

		[JsonProperty("created_at")]
        public string CreatedAt { get; set; } 

		[JsonProperty("updated_at")]
        public string UpdatedAt { get; set; } 
    }

    public class Root    {
	    [JsonProperty("Class1")]
        public Class1 Class1 { get; set; } 
    }

But what I get is this:

// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse); 
    public class Class1    {
        public int Id { get; set; } 
        public string UserId { get; set; } 
        public string CreatedAt { get; set; } 
        public string UpdatedAt { get; set; } 
    }

    public class Root    {
        public Class1 Class1 { get; set; } 
    }

Thanks

@Json2CSharp
Copy link
Owner

Fixed now with ad612c4 :) thanks for letting me know !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants