Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

C# Convert DataTable to Json File using Newtonsoft.Json DLL

 // Install Newtonsoft.Json from nuget
//then add namespace
//Using NewtonSoft.Json;

public bool Write(string filePath, DataTable table, string fileName)
        {
            try
            {
                bool success = false;
                using (var file = File.CreateText(filePath + "" + fileName))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, table);
                    success = true;
                }
                return success;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Comment

C# Convert Json File to DataTable using Newtonsoft.Json DLL

// Install Newtonsoft.Json from nuget 
// Use the namespace after
//Using Newtonsoft.Json;
public DataTable Read(string filePath)
        {
            try
            {
                //check if json structure is okay (http://jsonlint.com)
                //generate object class http://www.jsonutils.com

                DataTable dt = new DataTable();
                dt = JsonConvert.DeserializeObject<DataTable>(File.ReadAllText(filePath));

                return dt;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Comment

PREVIOUS NEXT
Code Example
Javascript :: to fix a broken class oop javascript 
Javascript :: get copied text javascript 
Javascript :: regex online converter 
Javascript :: react native mirror text 
Javascript :: Javascript array of array loop 
Javascript :: export from json 
Javascript :: Simple Mustache.js 
Javascript :: iterate over element parent jquery 
Javascript :: jquery search button 
Javascript :: Getting Terms From An Array 
Javascript :: socket io inside route express not working 
Javascript :: get longi and long with an adress react 
Javascript :: for in loop of javascript 
Javascript :: ms dyn crm associate n:m record js 
Javascript :: change button text dynamically angular 6 
Javascript :: adding amplify in index.js react native 
Javascript :: NodeJS Database initialisation 
Javascript :: prisma count non-null 
Javascript :: javascript hide div 
Javascript :: aws cognito user pool and angular 
Javascript :: useState intro 
Javascript :: Backbone View Event 
Javascript :: how to get on hnage input before clicking off 
Javascript :: merge large arrays 
Javascript :: run javascript after rendering 
Javascript :: javascript number reverse 
Javascript :: use of prototype in javascript 
Javascript :: modals in react native 
Javascript :: how to remove duplicates in js 
Javascript :: react native get screen height and width 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =