- Trending Categories
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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Suppose, we have a JSON Array that contains data about some tickets like this −const arr = [ { "quantity": "1", "description": "VIP Ticket to Event" }, { "quantity": "1", "description": "VIP Ticket to Event" }, { "quantity": "1", "description": "VIP Ticket to Event" }, { "quantity": "1", "description": "Regular Ticket to Event" }, { "quantity": "1", "description": "Regular Ticket to ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Suppose, we have an array of objects that contains data about some movies like this −const arr = [ {id: "1", name: "Snatch", type: "crime"}, {id: "2", name: "Witches of Eastwick", type: "comedy"}, {id: "3", name: "X-Men", type: "action"}, {id: "4", name: "Ordinary People", type: "drama"}, {id: "5", name: "Billy Elliot", type: "drama"}, {id: "6", name: "Toy Story", type: "children"} ];We are required to write a JavaScript function that takes in one such array as the first argument and an id string as the second argument. Then our function should search for the object ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Suppose, we have two JSON objects like these −const obj1 = {a: "apple", b: "banana", c: "carrot"}; const obj2 = {a: "apple", e: "egg", b: "banana", c: "carrot", d: "dog"};We are required to write a JavaScript function that takes in two such objects. We want to be able to have a Boolean check comparing the two objects without having to remove data from either one.For example, if I were to use the data above, the Boolean check should return true because the values of the keys that are in both objects match.However, let’s say obj1 stays the same but obj2 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
347 Views
Suppose, we have an array of objects like this −const arr = [ {"id":7, "name":"Kuwait", "parentId":2}, {"id":4, "name":"Iraq", "parentId":2}, {"id":10, "name":"Qatar", "parentId":2}, {"id":2, "name":"Middle East", "parentId":1}, {"id":3, "name":"Bahrain", "parentId":2}, {"id":6, "name":"Jordan", "parentId":2}, {"id":8, "name":"Lebanon", "parentId":2}, {"id":1, "name":"Africa/Middle East", "parentId":null}, {"id":5, "name":"Israel", "parentId":2}, {"id":9, "name":"Oman", "parentId":2} ];We are required to write a JavaScript function that takes in one such array. The function should then prepare a new array that contains the objects grouped according to their parents.Therefore, the output should look like this −const output = [ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Suppose, we have the following JSON object −const obj = { "test1": [{ "1": { "rssi": -25, } }, { "2": { "rssi": -25, } }], "test2": [{ "15": { "rssi": -10, } }, { "19": { "rssi": -21, } }] };We are required to write a JavaScript function that takes in an object like this −The ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
591 Views
Suppose, we have the following array of objects −const arr = [ { "date" : "2010-01-01", "price" : 30 }, { "date" : "2010-02-01", "price" : 40 }, { "date" : "2010-03-01", "price" : 50 }, { "date" : "2010-01-01", "price2" : 45 }, { "date" : "2010-05-01", "price2" : 40 }, { "date" : "2010-10-01", ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Suppose, we have the following JSON object −const obj = { "context": { "device": { "localeCountryCode": "AX", "datetime": "3047-09-29T07:09:52.498Z" }, "currentLocation": { "country": "KM", "lon": -78789486, } } };We are required to write a JavaScript recursive function that initially takes in one such array.The function should split the above object into a "label" - "children" format.Therefore, the output for the above object should look like −const output = { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
6K+ Views
Suppose we have the following nested JSON object −const obj = { id: 1, title: 'hello world', child: { id: null, title: 'foobar', child: { id: null, title: 'i should be in results array ' } }, foo: { id: null, title: 'i should be in results array too!' }, deep: [ { id: null, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
459 Views
Suppose, we have this JSON object where index keys are mapped to some literals −const obj = { "0": "Rakesh", "1": "Dinesh", "2": "Mohit", "3": "Rajan", "4": "Ashish" };We are required to write a JavaScript function that takes in one such object and uses the object values to construct an array of literals.ExampleThe code for this will be −const obj = { "0": "Rakesh", "1": "Dinesh", "2": "Mohit", "3": "Rajan", "4": "Ashish" }; const objectToArray = (obj) => { const res = []; const keys = Object.keys(obj); keys.forEach(el => { res[+el] = obj[el]; }); return res; }; console.log(objectToArray(obj));OutputAnd the output in the console will be −[ 'Rakesh', 'Dinesh', 'Mohit', 'Rajan', 'Ashish' ]
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
640 Views
We are required to write a JavaScript function that takes in a JSON object as one and only argument.The JSON object has string keys mapped to some numbers. Our function should traverse through the object, find and return the smallest value from the object.ExampleThe code for this will be −const obj = { "a": 4, "b": 2, "c": 5, "d": 1, "e": 3 }; const findSmallestValue = obj => { const smallest = Object.keys(obj).reduce((acc, val) => { return Math.min(acc, obj[val]); }, Infinity); return smallest; } console.log(findSmallestValue(obj));OutputAnd the output in the console will be −1