- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 206 Articles for JSON
3K+ Views
We can use JsonPath in Rest Assured to extract value. This is done with the help of the jsonPath method (which is a part of the JsonPath class). After that, we need to use the get method and pass the key that we want to obtain from the JSON Response.We shall first send a GET request via Postman on an endpoint and observe the JSON response. Here, the keys are userId, id, title, and body.ExampleCode Implementationimport org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; public class NewTest { @Test void getValueJsonPath() { ... Read More
1K+ Views
JavaScript Object Notation, or JSON is a simple data format that is used to exchange data between many different languages. It is simple to read for people and simple for computers to parse. Python reads JSON text as a quoted-string that contains the value in each key-value mapping. Once parsed, it is accessible in Python as a dictionary object. JSON data can be encoded and decoded using the built-in package json in Python. You must first import the json library in order to work with files of the json type. Purposeco JSON Python to JSON conversion is done using serialization. ... Read More
10K+ 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
3K+ Views
In this problem statement, our task is to add a unique id for every object entry in a JSON object with the help of Javascript. So for doing this task we will use a loop and a variable to store the id for each object in the JSON object. Understanding the problem statement The problem statement is to write a function in Javascript by which we can add a unique id to every item in the given JSON object. For updating every JSON object by adding new id to every object we will use basic Javascript functionality. For example we ... Read More
2K+ Views
Suppose, we have the following array in JavaScript −const arr = [{ "code": "2", "name": "PENDING" }, { "code": "2.2", "name": "PENDING CHILDREN" }, { "code": "2.2.01.01", "name": "PENDING CHILDREN CHILDREN" }, { "code": "2.2.01.02", "name": "PENDING CHILDREN CHILDREN02" }, { "code": "1", "name": "ACTIVE" }, { "code": "1.1", "name": "ACTIVE CHILDREN" }, { "code": "1.1.01", "name": "ACTIVE CHILDREN CHILDREN" }];We are required to write a JavaScript function that takes in one such array. The function should build a tree structure from this array based on ... Read More
538 Views
Suppose, we have a JSON array with key/value pair objects like this −const arr = [{ "key": "name", "value": "john" }, { "key": "number", "value": "1234" }, { "key": "price", "value": [{ "item": [{ "item": [{ "key": "quantity", "value": "20" }, { "key": "price", "value": "200" }] }] ... Read More
351 Views
Suppose, we have two arrays like these −const meals = ["breakfast", "lunch", "dinner"]; const ingredients = [ ["eggs", "yogurt", "toast"], ["falafel", "mushrooms", "fries"], ["pasta", "cheese"] ];We are required to write a JavaScript function that takes in two such arrays and maps the subarrays in the second array to the corresponding strings of the first array.Therefore, the output for the above arrays should look like −const output = { "breakfast" : ["eggs", "yogurt", "toast"], "lunch": ["falafel", "mushrooms", "fries"], "dinner": ["pasta", "cheese"] };ExampleThe code for this will be −const meals = ["breakfast", "lunch", "dinner"]; const ingredients ... Read More
11K+ Views
In the given problem statement we are asked to get value for key from nested JSON object with the help of javascript functionalities. In Javascript we can solve and access the json data object with the help of dot notation or bracket notation. Before starting coding for the given problem, let's understand what exactly is the JSON object: What is JSON and nested JSON objects? JSON’s full form is Javascript Object Notation. It is a standard text based format to show the structured data. It is basically used to transmit data in web applications, which means we can send ... Read More
370 Views
In the given problem statement we are asked to group the JSON object with the help of javascript functionalities. This problem can be solved with the help of a simple algorithm in javascript. What is JSON ? JSON (Javascript Object Notation) is lightweight data which can be transferred between two devices. This data can be read and written by humans. JSON objects are represented in the form of key−value pairs. Keys are strings to define values. In JSON each entry is separated by a semicolon. For example − {“Car” : “Audi”}, in this example Car is a key and Audi ... Read More
937 Views
Suppose, we have an array of objects like this −const arr = [ { "SupplierName" : "John", "Category " : "A", "Points" : 3 }, { "SupplierName" : "John", "Category " : "A", "Points" : 11 }, { "SupplierName" : "John", "Category " : "A", "Points" : undefined }, { "SupplierName" : "John", "Category " : "B", "Points" : 2 }, { "SupplierName" : "John", "Category " : "B", "Points" : 6 }, { "SupplierName" : "Praveen", "Category " : "A", "Points" : 3 }, { "SupplierName" : "Praveen", "Category " : "A", ... Read More