How to communicate JSON data between Java and Node.js ? Last Updated : 08 Apr, 2021 Comments Improve Suggest changes Like Article Like Report 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 programming language. Serialization using Java: Serialization is the process of converting programming data to JSON text. In Java, there is no inbuilt library for JSON readers. We need to either add a dependency in our grade project or download the jar file. We had Jackson and simple-json libraries. Here simple-json library is used. Let us generate a JSON file using java code as follows. Java import org.json.simple.JSONObject; import java.io.FileWriter; import java.io.IOException; public class MyClass { public static void main(String args[]) { JSONObject obj = new JSONObject(); obj.put("name", "Inshal Khan"); obj.put("Roll no", new Integer(42)); obj.put("cgpa", new Double(7.99)); try { FileWriter file = new FileWriter("E:/output.json"); file.write(obj.toJSONString()); file.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println("JSON file created: "+jsonObject); } } Output: JSON file created:{ "name":"Inshal Khan", "Roll no":"42", "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"} Comment More infoAdvertise with us Next Article How to communicate JSON data between Java and Node.js ? R regiscaelum Follow Improve Article Tags : Web Technologies Node.js JSON Similar Reads How to communicate JSON data between C++ and Node.js ? 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 a 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 How to Create and Manipulatinag JSON Data in javaScript? The JavaScript Object Notation (JSON) is a lightweight data interchange format commonly used for transmitting data between the server and a web application. The JSON data is represented as the key-value pairs and is easy to read and write for both humans and machines. In JavaScript, JSON objects can 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 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 Like