last day (14 days later) » 

10:03 AM
1
A: Deserialize nested JSON Response with RestSharp Client

JaanusTry using this as POCO: public class Course { public bool success { get; set; } public string message { get; set; } public List<CourseTypeContainer> Types { get; set; } } Now you have list of CourseTypeContainer. And CourseTypeContainer is public class CourseTypeContainer { pu...

 
Thanks, I just figured out the typo by myself as well :) I updated my question. It would list me now all Types, but those are all empty (null). What's wrong with my Code?
 
Can you check how many elements there are in response.Data.Types, then we know if atleast he gets something.
See my edited answer.
 
Yes it does get something. There are >2k response.Data.Types elements, but all of them are null..
 
Remove the container , just use list of CourseType.
 
Wow it really works when I use List<CourseType> Types!! :D Thank you so much!! Can you explain me, in which case I'd need a container?
Also, the Descriptions properties are still null. I think it's because of the JSON structure, since the "descriptions" property can contain different language (e.g. "EN") which contain all those descriptive properties (description, overview, ..). Is there a way I can get the descriptions for all languages without writing a POCO for each language?
 
10:38 AM
How about creating a new POCO class "AvnetCourseTypeDescriptionDetails" which contains all those descriptive attributes "Description", "Overview", etc. and adding a property for each language to the "AvnetCourseTypeDescription" class ot type List<AvnetCourseTypeDescriptionDetails>
I don't really like my own approach, cuz for each language a new property is required. So far it works like that, but if you have an idea, feel free to share it :)
 
hey
 
hey
 
you dont ever need containers basically if the data is structured as it is
 
you mean in case of plain text one need to parse the data and use a container?
 
well yeah, something like that
its just that, you have pretty JSON
and it transalted to objects as it looks
"types":
[
{
[ marks that it is list
and { marks the first object
list of objects
so you have it
 
10:43 AM
I see :)
 
did you get it to working_
description properties are null
show me the CourseType object
 
yes it works now :) but I had to add another poco class which contains the language
it works, but I'm not quite happy with the solution
 
can you show me what you have at the moment
show me inside coursetype
 
in my CourseType I have:
public List<CourseTypeDescription> Descriptions { get; set; }

in my CourseTypeDescription I have:
public List<CourseTypeDescriptionDetails> EN { get; set; }
public List<CourseTypeDescriptionDetails> DE { get; set; }

in my CourseTypeDescriptionDetails I have all the descreptive properties which used to be in CourseTypeDescription
 
you mean this? descriptions": {
"EN": {
"description": "some Text null",
"overview": null,
"abstract": "Some other text",
"prerequisits": null,
"objective": null,
"topic": null
}
 
10:46 AM
exactly
 
will contain DE and other stuff?
well this is bad practice, you would have to chance it on the API side
 
I'm not sure which language need to be supported. but at least I need DE (German) and EN (English)
I see. so there is no proper solution for me since the API is bad practice?!
 
yes not really
since you will have new custom elements there inside
can you change the API_
 
It would be nice if I didn't have to add an additional property for each language..
 
you would need it to return this
"descriptions": [
{
"language":"EN",
"description":"some Text null",
"overview":null,
"abstract":"Some other text",
"prerequisits":null,
"objective":null,
"topic":null
},
{
"language":"DE",
"description":"some Text null",
"overview":null,
"abstract":"Some other text",
"prerequisits":null,
"objective":null,
"topic":null
},
{
"language":"UA",
"description":"some Text null",
"overview":null,
"abstract":"Some other text",
"prerequisits":null,
"objective":null,
"topic":null
}
]
 
10:50 AM
yes that looks much prettier, I absolutely agree!
 
then you can have 1000 lists
 
yes
 
1000 languages*
 
I'll ask them if it's possible to change it, but I don't have much hope. :)
 
:)
 
10:51 AM
Anyway, you helped me a lot! Thank you very much for your support
 
sure, np
have a nice day
 
have a nice day, too:)
bye
 

last day (14 days later) »