Show / Hide Table of Contents

    DataStoreExtensions.ExportJson(DwBuffer dwbuffer, int startRow = 0, int endRow = -1, int startColumn = 0, int endColumn = -1, bool format = false) Method

    .NET Standard 2.x

    Exports all data or the specified rows and/or columns from the specified buffer to a plain JSON string or DataWindow JSON string.

    Namespace: PowerScript.Bridge

    Assembly: PowerScript.Bridge.dll

    Syntax

    public static string ExportJson(this IDataStoreBase dataStore, DwBuffer dwbuffer, int startRow = 0, int endRow = -1, int startColumn = 0, int endColumn = -1, bool format = false);
    

    Parameters

    dwBuffer DwNet.Data.DwBuffer

    A value of the DwBuffer enumerated datatype identifying the DataWindow buffer from which you want to export the data.

    startRow System.Int32

    The number of the first detail row in the buffer that you want to export. The default is 0. If it is negative, 0 is used.

    endRow System.Int32

    The number of the last detail row in the buffer that you want to export. The default is the rest of the rows. If it is negative, it indicates the rest of rows.

    startColumn System.Int32

    The number of the first column in the buffer that you want to export. The default is 0. If it is negative, 0 is used.

    endColumn System.Int32

    The number of the last column in the buffer that you want to export. The default is the rest of the columns. If it is negative, it indicates the rest of columns.

    format System.Boolean

    A boolean specifying the JSON format.

    True indicates the DataWindow JSON.

    False indicates the plain JSON. The default is false.

    Returns

    System.String

    Returns the JSON string if it succeeds.

    Examples

    The following code example exports the data of the first and second columns at the first and second rows from the primary buffer of DataStore to a plain JSON string.

    using System;
    using DWNet.Data;
    using PowerScript.Bridge;
    
    namespace Appeon.ApiDoc.DataStoreExtensionsExamples
    {
        public class ExportJsonExample
        {
            private readonly SchoolContext _context;
    
            public ExportJsonExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example4()
            {
                // Instantiates the datastore with datawindow: d_department
                var datastore = new DataStore("d_department", _context);
    
                datastore.Retrieve();
    
                // Exports data of 1st and 2nd columns at 1st and 2nd rows to plain JSON
                string json = datastore.ExportJson(DwBuffer.Primary, 0, 1, 0, 1, false);
    
                Console.WriteLine(json);
    
                /*The exported JSON file is:
    
                ExportJson4.json  
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    JSON File: ExportJson4
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon