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

Adding textbox value with button in C#
How to show the tooltip without any time duration?
How can i hide in game view a ui button and show the button when pressing the escape key?
TCP Connection. best way to handle multiple connections [duplicate]
Send POST request with Image from Unity3D
How to make default Password Reset functionality work in ASP.NET Core
UriTemplate Matching Email
Error handling between web api and angular 2 client
Get Duplicates in List and Edit Item
Should I await a 'async Task' function if I don't care its return value? [duplicate]
Autofac open generics: factory IIndex based on <U>
string with StingBuilder error c#
Mono SQLite with CF 3.5
EWS Oauth Exception: The request failed. The remote server returned an error: (401) Unauthorized
Reports in MS Word. Any library? [closed]
Display two model in a View?

Categories

HOME
azure-active-directory
intellij-idea
fortran
weblogic
where
ebay
sugarcrm
opacity
pdf-generation
genexus
pyodbc
angular-universal
ldap-query
email-attachments
tmux
minimum
dat.gui
jsfiddle
novacode-docx
google-drive-android-api
infinite-loop
wai-aria
concatenation
procedural-generation
devexpress-mvc
android-xml
scalatest
workflow-foundation
setup-project
delphi-2010
jmsserializerbundle
bootcamp
sampling
leaderboard
strategy-pattern
iterm2
origami
gem-fury
mtm
f#-fake
html-entities
opos
photoshop-script
aws-rds
business-catalyst
chain
apache-commons-cli
google-scholar
directinput
racket-student-languages
xcode7.1
rowname
require-handlebars
android-xmlpullparser
camellia
firefox-os
oryx
wordpress-plugin
google-finance-api
web-performance
jcomponent
taverna
dcg
minko
strcpy
touch-typing
random-access
agent-based-modeling
livescript
nsmutableurlrequest
fscanf
ccmenuitem
visual-c#-express-2010
html5-filesystem
node-mongodb-native
jython-2.5
azure-scheduler
generator-expression
django-tinymce
moonscript
m3u
django-1.4
cgaffinetransform
service-layer
activescaffold
large-data-volumes
user-preferences

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