That's ok. I have 2 tables . One is Master & other is for Item Details. From those tables i want that Json should be created according to the above Schema
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Use the tool of your choice to create the class objects for the json schema. Then map the database rows to the new objects. Your sql will return the tables as a product, which you will need to remap to a hierarchy. You could also use Sqlserver json support
to build the json string,
Member
45 Points
174 Posts
How to create Json according to below Schema
Feb 07, 2021 02:37 PM|jagjit saini|LINK
Hi
Thanks
All-Star
58144 Points
15641 Posts
Re: How to create Json according to below Schema
Feb 07, 2021 05:05 PM|bruce (sqlwork.com)|LINK
You can use vs2019 special paste of json as class or
https://json2csharp.com
Member
45 Points
174 Posts
Re: How to create Json according to below Schema
Feb 08, 2021 05:41 AM|jagjit saini|LINK
Hi
That's ok. I have 2 tables . One is Master & other is for Item Details. From those tables i want that Json should be created according to the above Schema
Thanks
Contributor
2690 Points
774 Posts
Re: How to create Json according to below Schema
Feb 08, 2021 06:57 AM|YihuiSun|LINK
Hi jagjit saini,
Do you want to convert the object to JSON?
string output = JsonConvert.SerializeObject(test);
You can click this link to see more explanation.
Best Regards,
YihuiSun
Member
45 Points
174 Posts
Re: How to create Json according to below Schema
Feb 08, 2021 08:36 AM|jagjit saini|LINK
Hi YihuiSun
I want to know how to pass values from Database to Object & then convert to Json
Thanks
Member
45 Points
174 Posts
Re: How to create Json according to below Schema
Feb 08, 2021 08:37 AM|jagjit saini|LINK
Hi Bruce
I want to know how to pass values from Database table to Object & then convert to Json. I have already created Objects.
Thanks
All-Star
58144 Points
15641 Posts
Re: How to create Json according to below Schema
Feb 08, 2021 03:35 PM|bruce (sqlwork.com)|LINK
Use the tool of your choice to create the class objects for the json schema. Then map the database rows to the new objects. Your sql will return the tables as a product, which you will need to remap to a hierarchy. You could also use Sqlserver json support to build the json string,