c#


How can we prepare a json object where objects has different attributes


I am working on a WEB API and need to return json result in this format:
{
"responseID": "b806d829-1d9c-4c69-8d7a-576ffc4de555",
"orders": [
{
"id": order1,
"status": "Issued",
"statusDate": "2017-04-05T10:00:56.1549453+00:00",
"amount": 100000,
"quantity": 10,
"fee": 99,
"comments": "some comments"
},
{
"id": order2,
"status": "Declined",
"statusDate": "2017-04-05T10:00:56.1549453+00:00",
}
]
}
Can we prepare a json object like this where the objects within array has different attributes like in the above example order1 has 7 attributes but order2 has only 3.
My understanding is that the only way to achieve the desired results is to change the format of json object as below:
{
"responseID": "b806d829-1d9c-4c69-8d7a-576ffc4de555",
"issuesOrders": [
{
"id": order1,
"status": "Issued",
"statusDate": "2017-04-05T10:00:56.1549453+00:00",
"amount": 100000,
"quantity": 10,
"fee": 99,
"comments": "some comments"
} ],
"declinedOrders": [
{
"id": order2,
"status": "Declined",
"statusDate": "2017-04-05T10:00:56.1549453+00:00",
}
]
}
Is my understanding is correct?

Related Links

Which MVC version to start with [closed]
What is “88-type” in C# and how can i use it?
C# Regex to convert yyyyMMddhhmm
EntityFramework package version=“6.1.3” and Web config version 6.0.0.0?
How to read a binary formatted string from a file?
Why My combobox binding not working
convert timespan to datetime
call to method inside code behind file(aspx.cs file) from controller method
Casting exposes private data via getter method
How to get a proper date from a text?
Problems converting an Oracle plsql stored procedure call to C# (invalid array bind size)
How to handle null value in entity framework sum function
Audio stream requested using HttpClient doesn't play until file is completely downloaded
Complex grouping in Linq? C#.net
How to prevent duplicate items from being added to an IRepository?
C# Convert All Dependency Properties to INotifyPropertyChanged

Categories

HOME
spring-boot
msbuild
kendo-ui-angular2
cors
jenkins-pipeline
customization
mysqli
reference
nagios
readdir
itext7
schema
rmarkdown
wavefront
doctrine2
subprocess
runtime
suitecrm
osclass
hdf5
element
k-means
simd
virtuemart
airbnb
draw2d
cherrypy
hololens
angular2-pipe
pushbullet
cqlsh
apm
foxpro
jql
visual-studio-debugging
choco
contextmenustrip
visual-prolog
eclipse-jdt
favorites
border-layout
abide
area
linkurious
file-conversion
ui-grid
text-extraction
result
niagara-ax
serverless-architecture
noise
serialversionuid
dna-sequence
enet
htop
r-commander
robotc
vertex-shader
breadcrumbs
qudpsocket
papyrus
alfred
foreground
rowname
airwatch
db2-zos
boost-bind
stdlist
google-app-engine-php
opendolphin
windows-kernel
javapackager
android-togglebutton
avd
asp.net-2.0
fiware-health
quickfixn
fedena
launcher
growl
yosemite
pytz
yandex-api
lettuce
autofilter
pyxplot
panelgrid
uikit-dynamics
brew
antixsslibrary
cryptarithmetic-puzzle
custom-cursor
waveout
aspmenu-control
systrace
bash4
animationdrawable
stl-algorithm
project-files
umfpack
openwrap
backlight
object-tag
hs-err
rollover
subdirectories
retrospectiva
scala-designer

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App