0

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"
  }
}
4

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much for helping me on this. it worked for me. great efforts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.