JSON Articles

Page 4 of 16

Get value for key from nested JSON object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 18K+ Views

In JavaScript, accessing values from nested JSON objects is a common task when working with APIs and complex data structures. We can retrieve nested values using dot notation, bracket notation, or custom functions. Before exploring different approaches, let's understand what JSON and nested JSON objects are: What is JSON and Nested JSON Objects? JSON (JavaScript Object Notation) is a lightweight, text-based format for representing structured data. It's widely used for data transmission between web applications and servers. Nested JSON objects contain objects within other objects, creating a hierarchical structure. Each nested property has a unique path ...

Read More

JSON group object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 869 Views

In JavaScript, grouping JSON objects means organizing data by common properties or categories. This is useful for data analysis, filtering, and creating structured reports from collections of objects. What is JSON? JSON (JavaScript Object Notation) is a lightweight data format for transferring data between devices. JSON objects use key-value pairs where keys are strings and values can be strings, numbers, booleans, arrays, or nested objects. For example: {"name": "Alice", "age": 25}. const jsonData = [ { team: 'TeamA', score: 20 }, { ...

Read More

Create array from JSON object JavaScript

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 2K+ Views

In this article, we will learn to create an array from JSON data in JavaScript. JSON is a widely used format for storing and exchanging data. A common use case involves extracting specific data from a JSON object or array and converting it into a separate array for further processing. What is JSON Data? JSON (JavaScript Object Notation) is a lightweight data format commonly used to store and exchange data between a server and a client. It represents data as key-value pairs and is easy for both humans and machines to read and write. In JavaScript, JSON objects ...

Read More

Escaping/encoding single quotes in JSON encoded HTML5 data attributes

George John
George John
Updated on 15-Mar-2026 4K+ Views

When embedding JSON data in HTML5 data attributes, single quotes can break HTML parsing. JavaScript provides several methods to properly escape or encode single quotes to ensure valid HTML output. The Problem with Single Quotes in Data Attributes Single quotes inside JSON values can break HTML attribute parsing when the attribute itself uses single quotes: // Problematic - single quote breaks HTML

Read More

JSON. stringify( ) function in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 312 Views

The JSON.stringify() method converts a JavaScript object or value to a JSON string. This is the reverse of JSON.parse() which converts JSON strings back to JavaScript objects. Syntax JSON.stringify(value, replacer, space) Parameters value: The JavaScript value to convert to JSON string (required) replacer: Function or array to transform values (optional) space: Number of spaces or string for indentation (optional) Basic Example JSON.stringify Example var obj = {Tutorial: "JavaScript", Version: "ES6", ...

Read More

How to convert MySQL DATETIME value to JSON format in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 719 Views

To convert MySQL DATETIME values to JSON format in JavaScript, you can parse the datetime string into a Date object and then use JSON.stringify() to convert it to JSON. This is useful when working with MySQL data in web applications. Understanding MySQL DATETIME Format MySQL DATETIME format is typically YYYY-MM-DD HH:MM:SS. JavaScript's Date constructor can parse various date formats, making conversion straightforward. Method 1: Converting to JSON Object with Individual Components This approach extracts individual date components and creates a structured JSON object: // Simulate MySQL DATETIME string var mySQLDateTime = new Date("2019-09-06 ...

Read More

Parsing JSON array with PHP foreach

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

In PHP, you can parse JSON arrays using json_decode() and iterate through them with foreach. The json_decode() function converts JSON strings into PHP arrays or objects. Syntax json_decode($json_string, $associative = false) Parameters Parameter Description $json_string The JSON string to decode $associative When true, returns associative array instead of object Example Here's how to parse a JSON array and access its nested values using foreach ? Output This will produce the following output ? 3490abc ...

Read More

How To Install and Configure MongoDB on CentOS 7

Sharon Christine
Sharon Christine
Updated on 15-Mar-2026 557 Views

In this article, we will learn how to install and configure MongoDB on CentOS 7. MongoDB is an open-source NoSQL database that stores documents in a JSON-like format called BSON. Unlike traditional relational databases, MongoDB doesn't require a predefined schema and offers high availability, performance, and automatic scaling capabilities. Prerequisites CentOS 7 installed on the Linux machine A user with root privileges Adding the MongoDB Repository By default, the MongoDB repository is not available in CentOS 7. We need to add the MongoDB repository to the local machine first. vi /etc/yum.repos.d/mongodb-org.repo ...

Read More

Difference between JSON and XML

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 443 Views

Both JSON and XML are popular data interchange formats used to store and transfer structured data between systems. JSON is lightweight and commonly used in web APIs, while XML is more verbose but offers richer features like schemas and namespaces. Same Data in Both Formats Here is how the same student data looks in JSON and XML ? JSON Format { "student": { "name": "Alice", "age": 20, ...

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
Showing 31–40 of 152 articles
« Prev 1 2 3 4 5 6 16 Next »
Advertisements