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

ListView wont refresh or update in C# Forms application
Using Named Keys in Array C# MVC razor
Parsing string to int, C# inside of an XSL stylesheet
setting row data on rowdatabound event
NSubstitute: Checking received methods with array arguments
web service - 400 bad request
Cryptographic Key Storage
Attach newly created element in LINQ for deleting
How to seperate C# data connection code into a class file [closed]
XML Element Name from T in Generic Class
Can anyone tell me why this C# email validation regular expression (regex) hangs?
Unrar file with subdirectory
Change color line in listview
Simple database for Windows 8
Displaying Images with C#
Convert sequences to Generic Lists with svcutil

Categories

HOME
ckan
system-calls
qemu
fortran
ldap
bigtable
highmaps
livecharts
esxi
symfony-3.2
cracking
select2
chef-recipe
background-image
nsoperation
k-means
amazon-data-pipeline
simd
aws-devicefarm
gpo
beaker-notebook
ng-tags-input
rvm
gsuite
nsopenpanel
drombler-fx
typeorm
angular-schema-form
emr
dynamics-ax-2012-r3
sphinx4
intermec
overflow
lines
language-detection
machine-code
android-geofence
motion
ngrok
mediastream
icu
amazon-rds-aurora
wufoo
smooth-streaming
api-key
piranha-cms
jsfl
stanford-nlp-server
dcom
runtime-permissions
cancan
audio-fingerprinting
wicketstuff
computed-properties
papyrus
dbi
virtualenvwrapper
avaudiorecorder
shtml
phpdesigner
abstract
wordpress-plugin
sqldataadapter
askbot
dynamics-nav-2013
app-data
newlib
play-json
jts
avrcp
sparkcore
tidesdk
valdr-bean-validation
ultraedit
touch-typing
xmlserializer
gnip
agent-based-modeling
visual-c#-express-2010
mvcgrid
pyalgotrade
django-tests
ant-contrib
hotlinking
node-mongodb-native
logo-lang
lastinsertid
maven-javadoc-plugin
jfilechooser
randomaccessfile
windows-scheduler
cocotron
msbuild-task
servicemanager
gmail-imap
invalidoperationexception
linear-interpolation
aspmenu-control
systrace
dancer
session-hijacking
overlays
file-processing
sessiontracking
functional-specifications
meego-harmattan
norton
azure-appfabric
s60
scala-designer
zend-acl
hotfix
memory-consumption





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