JSON Articles

Page 8 of 16

How can we check if a JSON object is empty or not in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 22-Apr-2025 12K+ Views

In this article, let's learn how to check if a JSON object has any values or not in Java. If you don't know about JSON, refer JSON. We will use the org.json library and its methods like isEmpty(), length(), and keys() to check if a JSON object is empty or not. We can check if a JSON object is empty or not using the following methods: Using isEmpty() method Using length() method Using keys() method Let's see how to use each of them one by one. ...

Read More

How to convert a JSON array to CSV in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 22-Apr-2025 6K+ Views

JSON is a lightweight data interchange format. It is mostly used in web applications for sending and receiving data. To know more about JSON, refer JSON. A JSON array is a collection of JSON objects. It is similar to a list in Java. CSV is the format for storing tabular data in plain text. It is a comma-separated value. It is used for data exchange between applications. Let's see how CSV format looks like: JSON array The following is an example of the JSON array: [ { "Name": "Ansh", ...

Read More

When can we use a JSONStringer in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 22-Apr-2025 599 Views

A JSONStringer provides a convenient way of producing JSON text, and it can strictly follow to JSON syntax rules. Each instance of JSONStringer can produce one JSON text. A JSONStringer instance provides a value method for appending values to the text and a key-method for adding keys before values in objects. We have array () and endArray() methods that create and bind array values, and object() and endObject () methods that create and bind object values. It is part of the org.json library. It is generally used in Android and lightweight Java programs. In this article, we will learn when to use a JSONStringer in Java. When to use ...

Read More

How to pretty print JSON using the Gson library in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 22-Apr-2025 4K+ Views

JSON is a data interchange format that is easy to read and write. It is lightweight and gets parsed easily. It is commonly used in web applications for sending and receiving data. To know more about JSON, refer to JSON. Pretty print is a type of formatting that formats data in a more easily readable way by adding indentation and line breaks. It is useful for debugging and logging purposes. Enabling pretty print Using Gson Library Gson is a JSON library for Java, which was created by Google. By using Gson, we can generate JSON and convert JSON to Java objects. ...

Read More

How to construct a JSON object from a subset of another JSON object in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 21-Apr-2025 4K+ Views

In this article, we will learn how to construct a JSON object from a subset of another JSON object in Java. If you are not familiar with JSON and its usage in Java, you can refer to our JSON Overview tutorial. JSON Object From a Subset of Another Object There is more than one way to construct a JSON object from a subset of another JSON object in Java. Some of the popular libraries that we can use are - Using org.json library Using Gson library Using ...

Read More

How to Convert Base64 to JSON String in JavaScript?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 03-Jan-2025 1K+ Views

Base64 encoding is widely used as an ASCII string to represent binary data. However, converting Base64 strings to JSON is a common data exchange specification. This is because JSON is a human-readable format and is easily converted into JavaScript. In this article, we will explore methods to convert Base64 string to JSON string by giving examples and output for each. What is Base64? Base64 is a type of encoding scheme that represents binary data in an ASCII string. It generally gets used to encode an image, file, or other non-textual data to transfer safely across a text-based protocol like ...

Read More

How to read and write JSON file using Node?

Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 03-Jan-2025 1K+ Views

Node.js provides powerful tools for working with files, including reading and writing JSON files. JSON (JavaScript Object Notation) is widely used for storing and exchanging data in applications. This article walks you through reading and writing JSON files in Node.js with examples. Approaches to Read JSON file Using fs.readFileSync (Synchronous) Using fs.readFile (Asynchronous) JSON File data.json { "name": "PankajBind", "age": 21, "skills": ["JavaScript", "Node.js", "React"] } Using fs.readFileSync (Synchronous) The fs module in Node.js provides methods to interact with the file ...

Read More

Inventory Management with JSON in Python

Arpana Jain
Arpana Jain
Updated on 12-Oct-2023 815 Views

Inventory Management with JSON : Introduction Any firm that handles and tracks items or products needs to have effective inventory management. In order to guarantee that there is a sufficient supply of goods for clients and avoid overstocking or stockouts, it entails the process of monitoring and controlling the input and outflow of commodities. We'll look at using JSON for inventory management in Python in this tutorial. Inventory Management with JSON Definition JSON, or JavaScript Object Notation, is a simple data exchange format that is simple for both humans and robots to read and write. For data sharing between ...

Read More

How can we read a JSON file in Java?

raja
raja
Updated on 02-Sep-2023 62K+ Views

The JSON is one of the widely used data-interchange formats and is a lightweight and language independent. The json.simple is a lightweight JSON processing library that can be used to read and write JSON files and it can be used to encode or decode JSON text and fully compliant with JSON specification (RFC4627). In order to read a JSON file, we need to download the json-simple.jar file and set the path to execute it.json fileExampleimport java.io.*; import java.util.*; import org.json.simple.*; import org.json.simple.parser.*; public class JSONReadFromTheFileTest {    public static void main(String[] args) {       JSONParser parser = new JSONParser();       try {     ...

Read More

How to Convert Scrapy items to JSON?

Mukul Latiyan
Mukul Latiyan
Updated on 03-Aug-2023 508 Views

Web scraping is the process of extracting data from websites. It involves parsing HTML or XML code and extracting relevant information from it. Scrapy is a popular Python−based web scraping framework that allows you to easily build web scrapers to extract structured data from websites. Scrapy provides a robust and efficient framework for building web crawlers that can extract data from websites and store it in various formats. One of the key features of Scrapy is its ability to parse and store data using custom Item classes. These Item classes define the structure of the data that will be extracted ...

Read More
Showing 71–80 of 152 articles
« Prev 1 6 7 8 9 10 16 Next »
Advertisements