At the moment, I can retrieve database values via datasets and put them in a basic JSON format with the JSONCOnvert.serialize() in c#, but I need to generate all the section titles, divisions, arrays within arrays, etc. Each section would be a class and list of class? But how do i make the section titles and the title "mainSection", and the arrays within the values like the different clients?
Currently not using Newton.
I need to generate a file like such from database values:
{
"mainSection": [
{
"section1":
[
"curr_month" : "February",
"curr_year" : "2018",
"todays_date" : "02-02-2018",
"dates" :
[
"29",
"30",
"31",
"01",
"02",
"03",
"04"
]
]
},
{
"section2" :
[
"date_range_start" : "02-01-2018", //the range for kpi's is always from the 1st day of the month through yesterday
"date_range_end" : "02-01-2018"
]
},
{
"section3" :
[
"date_range_start" : "2-1-2018",
"date_range_end" : "2-28-2018",
"title" :
{
"count" : "225",
"percentage" : "0"
},
"asecondtitle" :
{
"count" : "2645233",
"percentage" : "9"
},
"athirdtitle" :
{
"count" : "437371",
"percentage" : "7"
}
]
},
{
"section4" :
[
"title" : "Today'",
"total_tile_count" : 4,
"listofclients" :
[
{
"client_id" : "123456"
"type" : "walkin",
"otherdata" : 13,
"client_name" : "Client P0opyface",
"appointment_times":
[
{
"scheduled_room" : "Room A", //sometimes they change operating rooms within the same day
"start_time" : "07:00",
"end_time" : "07:15"
},
{
"scheduled_room" : "Room B",
"start_time" : "07:15",
"end_time" : "07:30"
},
{
"scheduled_room" : "Room C",
"start_time" : "07:30",
"end_time" : "07:45"
}
]
},
{
"client_id" : "789"
"type" : "walkin",
"otherdata" : 13,
"client_name" : "Client Stinkyface",
"appointment_times":
[
{
"scheduled_room" : "Room D", //sometimes they change operating rooms within the same day
"start_time" : "07:00",
"end_time" : "07:15"
},
{
"scheduled_room" : "Room E",
"start_time" : "07:15",
"end_time" : "07:30"
},
{
"scheduled_room" : "Room F",
"start_time" : "07:30",
"end_time" : "07:45"
},
{
"scheduled_room" : "Room G",
"start_time" : "08:30",
"end_time" : "08:45"
}
]
},
{
"client_id" : "8675309"
"type" : "repeat",
"otherdata" : 13,
"client_name" : "Client Donkeybutt",
"appointment_times":
[
{
"scheduled_room" : "Room H", //sometimes they change operating rooms within the same day
"start_time" : "07:00",
"end_time" : "07:15"
},
{
"scheduled_room" : "Room I",
"start_time" : "07:15",
"end_time" : "07:30"
}
]
}
]
]
}
]
}
I have never seen such format, and I'm not able to create one either :
{
"section1": [
"curr_month" : "February",
"curr_year" : "2018",
"todays_date" : "02-02-2018"
]
}
So, either you mean this :
{
"section1": {
"curr_month": "February",
"curr_year": "2018",
"todays_date": "02-02-2018"
}
}
when the property "section1" is a User Defined Class, OR a Dictionary
Or this :
{
"section1": [
{
"curr_month": "February",
"curr_year": "2018",
"todays_date": "02-02-2018"
}
]
}
when the property "section1" is an array of a User Defined Class OR a Dictionary
So, if this is a typo by accident, I would say using one well constructed class is your best choice, unless if this JSON format is exactly what you really want. In that case, as far as I know, you may construct the format by using string concatenation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.