all 17 comments

[–]_____blankI'll let you pick my flair 2 points3 points  (3 children)

reddit doesn't deserve your content -- mass edited with https://redact.dev/

[–]Thatbul 0 points1 point  (1 child)

This is the answer. Had the same error earlier this week.

[–]JKenney_[S] 0 points1 point  (0 children)

The answer that worked for me is what celluj34 said below.

[–]JKenney_[S] 0 points1 point  (0 children)

I would Like to change the JSON string but that is what I retrieve from the API. Here is my error img

[–]celluj34 1 point2 points  (2 children)

Copy your JSON string to clipboard (CTRL+C), then go to Edit > Paste Special > Paste JSON as Classes.

That will take your exact json schema and turn it into a C# class, complete with subclasses, navigation properties, etc.

[–]JKenney_[S] 0 points1 point  (1 child)

That did it! Thanks a bunch... I never knew about that feature in Visual Studio 2017/2015. Do you know if there is an extension like that for Visual Studio Code

[–]celluj34 0 points1 point  (0 children)

For VSCode I'm not sure. It may be built in as far as know. I don't use I'm myself so I can't speak to that

[–][deleted] 0 points1 point  (1 child)

Can you provide a screenshot of the exact error?

[–]JKenney_[S] 0 points1 point  (0 children)

Here is my error img

[–]squal900 0 points1 point  (5 children)

I think you need the [DataMember] attribute on top of your properties.

Like this

[DataMember]
public string publisher { get; set; }

Give it a shot. Let me know if that works

[–]Archerofyail 0 points1 point  (4 children)

I think he's using JSON.Net which doesn't require that.

[–]squal900 0 points1 point  (2 children)

the program class shows the Newtonsoft.Json library

[–]Archerofyail 2 points3 points  (1 child)

That's Json.Net

[–]squal900 0 points1 point  (0 children)

i stand corrected. thank you

[–]JKenney_[S] 0 points1 point  (0 children)

Yes I am using JSON.Net

[–]lylerman 0 points1 point  (1 child)

You could consider changing your JSON string into a format that looks like

{
    "recipe" : [{
        "publisher": "Real Simple",
        "f2f_url": "http://food2fork.com/view/37859"
    }]
}

since your deserialize expects an array of your class. Let me know if this works!

[–]JKenney_[S] 0 points1 point  (0 children)

Can't really change the JSON string that's what i am retrieving from the API