JSON Articles

Found 152 articles

Flattening a JSON object in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 14K+ Views

Suppose, we have the following JSON object that may contain nesting upto any level −const obj = {    "one": 1,    "two": {       "three": 3    },    "four": {       "five": 5,       "six": {          "seven": 7       },       "eight": 8    },    "nine": 9 };We are required to write a JavaScript function that takes in one such nested JSON object and returns a new object that contains no nesting and maps the corresponding values to the keys using the dot ...

Read More

Parsing JSON array with PHP foreach

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 7K+ Views

The below code can be used to parse JSON array −Example

Read More

JSON. stringify( ) function in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 302 Views

The stringify() function of a JSON object accepts a JSON string, and constructs an object based on the given text and, returns it.SyntaxIts Syntax is as followsJson.stringify();Example    JavaScript Example           var jsonSample = '{Tutorial: Java, Version:8}';       jsonObj = JSON.stringify(jsonSample);       document.write(jsonObj);     Output"{Tutorial: Java, Version:8}"

Read More

How can we format a date using the Jackson library in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 01-Sep-2025 3K+ Views

Jackson is a Java-based library, and it can be useful to convert Java objects to JSON and JSON to Java objects. A Jackson API is faster than other API, needs less memory, and is good for large objects. We can format a date using the setDateFormat() of ObjectMapper class. This method can be used for configuring the default DateFormat when serializing time values as Strings and deserializing from JSON Strings. Syntax of setDateFormat() public ObjectMapper setDateFormat(DateFormat df) Here, df is the DateFormat instance to be used for formatting dates. Steps to format a date using Jackson in Java Following ...

Read More

Convert POJO to XML using the Jackson library in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 01-Sep-2025 7K+ Views

Jackson is a library that allows you to convert Java objects into XML and vice versa. In this example, we will demonstrate how to convert a POJO (Plain Old Java Object) into XML using the Jackson library. Well, if you are not familiar with POJO, it is a simple Java object that does not follow any specific framework or design pattern. It is just a regular Java class with fields and methods. We will use the method writeValueAsString() of the XmlMapper class to convert a POJO into XML. The XmlMapper class is part of the Jackson library and it ...

Read More

How can we ignore the fields during JSON serialization in Java?

Aishwarya Naglot
Aishwarya Naglot
Updated on 01-Sep-2025 14K+ Views

If there are fields in Java objects that do not wish to be serialized, we can use the @JsonIgnore annotation in the Jackson library. The @JsonIgnore can be used at the field level, for ignoring fields during the serialization and deserialization. In this article, we will learn how to ignore the fields during JSON serialization in Java using the Jackson library. Steps to ignore the fields during JSON serialization in Java: In order to use Jackson, you will need to add it to your project. If you use Maven, add the following dependency to your ...

Read More

How to Convert String to JSON using Python?

Yaswanth Varma
Yaswanth Varma
Updated on 17-Jun-2025 3K+ Views

In this article, we are going to learn how to convert a string to JSON in Python. JSON is a lightweight data interchange format that is used to read and write, and store data. Usually, we receive JSON data in the form of a string. To process it using a Python program, we need to convert the JSON string into an object, which can be stored in Python dictionaries and lists. This conversion can be done by using functions provided by the Python JSON module. Using Python json.loads() Function The Python json.loads() function is used to convert the JSON-formatted ...

Read More

How can we convert a JSONArray to String Array in Java?

Manisha Chand
Manisha Chand
Updated on 06-Jun-2025 4K+ Views

A JSONArray is a class provided by the org.json package that represents a collection of JSON values. These values can be of any type, such as strings, numbers, booleans, or even nested objects or arrays. If you do not know what JSON is, then you can read the JSON tutorial. Converting JSON Array to String ArrayWe can convert a JSONArray to String Array by using a simple loop as shown in the example below - import org.json.*; import java.util.*; public class JsonArraytoStringArrayTest { public static void main(String[] args) { ...

Read More

How can we convert a JSON array to a list using Jackson in Java?\\n

Aishwarya Naglot
Aishwarya Naglot
Updated on 05-Jun-2025 9K+ Views

Jackson is a Java-based library, and it can be useful for converting Java objects to JSON and JSON to Java objects. A Jackson API is faster than other API, needs less memory, and is good for large objects. We can convert a JSON array to a list using the ObjectMapper class. It has a useful method,  readValue(), which takes a JSON string and converts it to the object class specified in the second argument. Before proceeding further, first of all, we need to import the Jackson library into our project. To do this, you can add the following dependency to ...

Read More

Differences between org.simple.json and org.json libraries in Java?

Manisha Chand
Manisha Chand
Updated on 20-May-2025 3K+ Views

In Java, org.simple.json and org.json are two libraries that help in reading, writing, and manipulating JSON. But still, they are different. In this article, we are going to learn about these differences. Difference between JSON.simple vs JSON Let's see the below differences and they are - Features JSON.simple JSON ...

Read More
Showing 1–10 of 152 articles
« Prev 1 2 3 4 5 16 Next »
Advertisements