maui deserialize problem
I am having a problem when trying to deserialize api data
// this is what content says [{"id":1,"name":"Paprika chips","brand":"Lays","store":"Aldi"},{"id":2,"name":"producttest","brand":"brandttest","store":"Lidl"} so this one is correct but only the deserialize gives me some kind of problem and i do not understand why
this is what mylists says System.Collections.Generic.List`1[Boodschappenlijst.Model.Item]
10 Replies
JsonSerializer is case sensitive by default
also
.ToString()
returns the type by default
it doesnt return the contents of the list
you can use string.Join
for that
or even better, use the debuggerSO bassicaly the I in Id
and what do you mean with use the debugger
put a breakpoint after deserializing and check the contents of list
rather than logging
oh okey
JsonSerializerOptions.PropertyNamingPolicy Property (System.Text.Json)
Gets or sets a value that specifies the policy used to convert a property's name on an object to another format, such as camel-casing, or null to leave property names unchanged.
so you can use PascalCase for the class properties in c#
i see now bassicaly i was just printing the type instead of the data
yup
also use PascalCase for propertie names :)
thank you for your help
and yes i forgot you are right
np