Reputation: 217
I want to create a table that will generate this kind of JSON string:
{
"imagename": "Picture1",
"date": "03.09.2014",
"customer": {
"customernumber": "8",
"name": "any customer name"
}
}
Upvotes: 0
Views: 1102
Reputation:
Create the table as is but exclude the field customer, something like this:
CREATE TABLE [dbo].[aTable](
[ImageName] [nchar](10) NULL,
[Date] [nchar](10) NULL,
[CustomerNumber] [nchar](10) NULL,
[Name] [nchar](10) NULL
) ON [PRIMARY]
Select data from the table and create a dynamic object to assign the data (hard coded values as example):
var dyna = new {imageName = "Picture1", date = "03.02.2014", customer = new {customerNumber = "8", name = "any cust name"}};
Then serialize the dyna object using a JSON serializer.
Upvotes: 1