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

Need example of how to deserialize into these generated classes #158

Open
KlomDark opened this issue Jun 18, 2024 · 1 comment
Open

Need example of how to deserialize into these generated classes #158

KlomDark opened this issue Jun 18, 2024 · 1 comment

Comments

@KlomDark
Copy link

Hi, trying very hard to figure out how to actually use these generated classes. I don't see anything about deserializing into them. Can I get an example please? I just end up with the class with all fields null.

Is there a special trick built into these classes?

I am trying the old school way like this:

GeneratedClassName response = null;
object json = JsonConvert.DeserializeObject(responseData);
if (json is JObject jObject)
{
  response = jObject.ToObject<GeneratedClassName>();
}

Any assistance greatly appreciated!

@Husqvik
Copy link
Owner

Husqvik commented Jun 18, 2024

JsonConvert.DeserializeObject<GeneratedClassName>(responseData)

should normally work. I see you use default serializer settings. If the field name doesn't perfectly match property name it will not be deserialized.

Provide the actual json and the GeneratedClassName definition se we can see what's the problem.

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