JSON
text-based open standard designed for human-readable data interchange
JSON (JavaScript Object Notation) is a way of expressing information.[1] JSON is usually easy to understand. It can express information like XML.[2] It is based on JavaScript's notation for object literals.[3] However, JSON is stricter.[3]
JSON and XML are both often used in AJAX.[4] Even though JSON is named after JavaScript, it can be used in other programming languages, such as Python (PHP, etc.)[5]
Example
This is an example of JSON:
{ "firstName": "John", "lastName" : "Smith", "age" : 25, "address" : { "streetAddress": "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : "10021" }, "phoneNumber": [ { "type" : "", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }
JSON Encoding and Decoding in Python
Encoding:
import jsonsampleDict = { "firstName": "John", "lastName" : "Smith"}sampleJson = json.dumps(sampleDict, indent=4)
Decoding:
import json# A JSON string or can be a JSON responsesampleJson = """{ "firstName": "John", "lastName" : "Smith"}"""sampleDict = json.loads(sampleJson)print(sampleDict['firstName'])print(sampleDict['lastName'])
References
Other websites
🔥 Top keywords: Main PageSpecial:Search0Slash (punctuation)BlackSpecial:RecentChanges4 (number)DavidSOLID (object-oriented design)Wikipedia:AboutFile:Sexual intercourse with internal ejaculation.webmHelp:ContentsHelp:IntroductionLisa Sparxxx2023 UEFA Champions League FinalColour24-hour clockAdolf Hitler UunonaBismillahir Rahmanir Raheem6 (number)T. N. SeshanFile:ASCII-Table-wide.svg20 (number)Poor Things (movie)United StatesCristiano RonaldoList of people who have walked on the MoonAli Malikov50 (number)17 (number)The Valley (2024 TV series)GrassList of mathematical symbolsList of U.S. states and territories by time zone8 (number)List of countries by areaWikipedia:Simple talkList of largest Hindu templesRama