DataSet2JSON 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package DataSet2JSON --version 1.0.1
NuGet\Install-Package DataSet2JSON -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DataSet2JSON" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DataSet2JSON --version 1.0.1
#r "nuget: DataSet2JSON, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DataSet2JSON as a Cake Addin
#addin nuget:?package=DataSet2JSON&version=1.0.1

// Install DataSet2JSON as a Cake Tool
#tool nuget:?package=DataSet2JSON&version=1.0.1

This will convert the DataSet to JSON output as the name suggests.

Let's begin. Its just 1 steps process after adding the reference.

Create object for formatter

Code side changes

DataSet2JSON.Formatter convertToJSON = new DataSet2JSON.Formatter();
convertToJSON.FormatDataSet(ds);  // Your Dataset

This will return the output as JObject

Database side changes

First line of the select query should always be a config file.

select '1:Books';   // This is our configuration which will be explained
select id,booktitle from tbl_books;

Output

{
    "Books":[{
        "id":1,
        "booktitle":"Some text"
    },{
        "id":2,
        "booktitle":"Some text2"
    }]
}

By this you can understand that the config is converted to JSON. Now let us see how to change "id" of the Books to "BookID".

select '1:Books';
select id as BookID,booktitle as Title from tbl_books;

Output

{
    "Books":[{
        "BookID":1,
        "Title":"Some text"
    },{
        "BookID":2,
        "Title":"Some text2"
    }]
}

Now lets get only single book as output. The above Books is a list now I need a single object.

select '1:Books:single';

Output

{
    "Books":{
        "BookID":1,
        "Title":"Some text"
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2022.1.6 2,086 1/6/2022
2021.4.14 551 4/14/2021
1.0.4 1,238 7/2/2018
1.0.3 932 7/2/2018
1.0.2 930 7/1/2018
1.0.1 903 7/1/2018
1.0.0 928 7/1/2018