- 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
![raja](https://www.tutorialspoint.com/assets/profiles/107595/profile/60_161286-1564642329.jpg)
5K+ Views
The JSON stands for JavaScript Object Notation and it can be used to transfer and storage of data. The JSONObject can parse text from a String to produce a map-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant object serialization. The JSONArray can parse text from a String to produce a vector-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant array serialization.In the below two examples, We can convert a JSON string to a JSON object.Example 1import org.json.JSONObject; import org.json.JSONArray; public class StringToJSONTest { public static void main(String args[]) { ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
988 Views
GSON is java library, It is used to convert OBJECT to JSON and JSON to Object. Internally it going to work based on serialization and deserialization.This example demonstrates how to convert HASHAMP to JSON using GSON library.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code in build.gradle.apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.example.andy.myapplication" minSdkVersion 15 targetSdkVersion 28 versionCode ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
231 Views
We can store data in MySQL as JSON with the help of JSON data type. The following is an example. Let us now create a table. mysql> CREATE table JsonAsMySQLDemo -> ( -> id int, -> name varchar(100), -> PageDemo JSON, -> eventInfo JSON -> ); Query OK, 0 rows affected (0.67 sec) Storing records into JSON data type. mysql> INSERT into JsonAsMySQLDemo values -> ( -> 1, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
5K+ Views
The delete() function of Map object accepts a string representing the key of an element of a map and deletes from the current Map object. This function returns true if the specified key exists in the map object else it returns false.SyntaxIts Syntax is as followsmapVar.delete()Example Live Demo JavaScript Example var mapVar = new Map(); mapVar.set('1', 'Java'); mapVar.set('2', 'JavaFX'); mapVar.set('3', 'HBase'); mapVar.set('4', 'Neo4j'); var map = mapVar.delete('4'); document.write("Size of the map object: "+mapVar.size); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
210 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 Live Demo JavaScript Example var jsonSample = '{Tutorial: Java, Version:8}'; jsonObj = JSON.stringify(jsonSample); document.write(jsonObj); Output"{Tutorial: Java, Version:8}"
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The json module in python allows you to dump a dict to json format directly. To use it,Exampleimport json my_dict = { 'foo': 42, 'bar': { 'baz': "Hello", 'poo': 124.2 } } my_json = json.dumps(my_dict) print(my_json)OutputThis will give the output −'{"foo": 42, "bar": {"baz": "Hello", "poo": 124.2}}'You can also pass indent argument to prettyprint the json. exampleimport json my_dict = { 'foo': 42, 'bar': { 'baz': "Hello", 'poo': 124.2 } } my_json = json.dumps(my_dict, indent=2) print(my_json)OutputThis will give the output −{ "foo": 42, "bar": { "baz": "Hello", "poo": 124.2 } }
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
19K+ Views
You need to decode the bytes object to produce a string. This can be done using the decode function from string class that will accept then encoding you want to decode with. examplemy_str = b"Hello" # b means its a byte string new_str = my_str.decode('utf-8') # Decode using the utf-8 encoding print(new_str)OutputThis will give the outputHelloOnce you have the bytes as a string, you can use the JSON.dumps method to convert the string object to JSON. examplemy_str = b'{"foo": 42}' # b means its a byte string new_str = my_str.decode('utf-8') # Decode using the utf-8 encoding import json d = json.dumps(my_str) ... Read More
![Niharika Aitam](https://www.tutorialspoint.com/assets/profiles/654775/profile/60_3867437-1684125242.jpg)
793 Views
JSON can be abbreviated as JavaScript Object Notation. It means a script of a text file in a programming language to transfer and store the data. It is supported by the python programming language using a built-in package named json. It’s text is given in the quoted string format which contains a key and value within the curly braces{} which looks like a dictionary. To access a JSON document using python we have to import the json package. In this package we have a method named dumps() which is used to convert the python tuple objects into the Java ... Read More
![Rajendra Dharmkar](https://www.tutorialspoint.com/assets/profiles/9963/profile/60_124173-1512724240.jpg)
907 Views
We can use python-jsonschema-objects which is built on top of jsonschema.The python-jsonschema-objects provide an automatic class-based binding to JSON schemas for use in Python.We have a sample json schema as followsschema = '''{ "title": "Example Schema", "type": "object", "properties": { "firstName": { "type": "string" }, "lastName": { "type": "string" }, "age": { "description": "Age in years", ... Read More