How to communicate JSON data between C++ and Node.js ? Last Updated : 31 May, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will use JSON data to communicate between two programs called C++ and Node.js. We can use a common text format to communicate, but text format will contain a lot of complexities. However, JSON is lightweight and easy to use. JSON is language-independent and hence can be used by any programming language. Serialization using C++: Serialization is the process of converting programming data to JSON text. In C++, there is no inbuilt library for JSON readers. We need to add the header file to our project. You will basically need json.hpp file for your C++ project to do the below-described stuff. Let us generate a JSON file using C++ code as follows. C++ #include<iostream> #include<ofstream> #include "json.hpp" // For convenience using json = nlohmann::json; using namespace std; int main(){ json obj; obj["Name"] = "Inshal"; obj["Roll no"] = "42"; obj["Dept"] = "CSE"; obj["cgpa"] = "7.99"; ofstream file("output.json"); file<<setw(4)<<obj<<endl; file.close(); cout<<"JSON Object Created:"; for (auto& element : obj) { cout << element << '\n'; } } Output: JSON Object Created:{ "Name":"Inshal", "Roll no":"42", "Dept":"CSE", "cgpa":"7.99" } Deserialization using Node.js: JavaScript 'use strict'; const fs = require('fs'); fs.readFile('output.json', (err, data) => { if (err) throw err; let obj = JSON.parse(data); console.log(obj); }); console.log('File Reading completed'); Output: JSON file created:{ "name":"Inshal Khan", "Roll no":"42", "cgpa":"7.99"} File Reading completed Comment More infoAdvertise with us Next Article How to Add Data in JSON File using Node.js ? R regiscaelum Follow Improve Article Tags : Node.js JSON NodeJS-Questions Similar Reads How to communicate JSON data between Java and Node.js ? So here we will use JSON to communicate between two programs called Java and Node.js. We can use a common text format to communicate, but text format will contain a lot of complexities. However, JSON is lightweight and easy to use. JSON is language-independent and hence can be used by any programmin 2 min read How to communicate JSON data between Python and Node.js ? The following article covers how to communicate JSON data between Python and Node.js. Suppose we are working with the Node.js application, and we want to make use of a specific library that is only available in python or vice versa. We should be able to share the results from one language to another 7 min read Communication Between two Programs using JSON JSON stands for JavaScript Object Notation. To communicate between computer and human we use a programming language. To communicate between two programs, there must be a common data format and here we use JSON format. Let us say you have an application with Frontend written in Python and Backend wri 3 min read How to Add Data in JSON File using Node.js ? JSON stands for Javascript Object Notation. It is one of the easiest ways to exchange information between applications and is generally used by websites/APIs to communicate. For getting started with Node.js, refer this article.Prerequisites:NPM NodeApproachTo add data in JSON file using the node js 4 min read How to work with Node.js and JSON file ? Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. With node.js as backend, the developer can maintain a single codebase for an entire application in javaScript.JSON on the other hand, stands for JavaScript Object Notation. It is a lightweight format for storing and exchanging d 4 min read How to Receive JSON Data at the Client Side ? For sending and receiving data to or from the server JSON format is used. JSON stands for Javascript Object Notation and it is a widely used format nowadays because of its advantages and simplicity. In this article, we will use XML HttpRequest to receive data from the server and use NodeJS for the b 2 min read Like