JSON
JavaScript Object Notation (JSON) is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
Overview[edit | edit source]
JSON is built on two structures:
- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
These are universal data structures that virtually all modern programming languages support, in one form or another. It is this universality that has contributed to JSON's success as a data interchange format.
Syntax[edit | edit source]
The JSON format is syntactically identical to the code for creating JavaScript objects. Because of this, a JSON data structure can be directly used in JavaScript, making it an ideal way to transmit data in web applications. A JSON object is written inside curly braces, with key/value pairs separated by commas. Keys are written as strings, followed by a colon, followed by the value associated with the key. Values can be strings, numbers, objects, arrays, true, false, or null.
MIME Type[edit | edit source]
The official MIME type for JSON is application/json.
JSONP[edit | edit source]
JSONP (JSON with Padding) is a method used to request data from a server residing in a different domain than the client. It is an effective workaround to browser restrictions, preventing web pages from making requests to a different domain than the one that served the web page.
Usage[edit | edit source]
JSON is widely used in web applications to exchange data between a browser and a server. The data can be sent from the server to the browser in JSON format and used directly in JavaScript scripts, or it can be converted from JSON to another format to be used in other types of applications. JSON is also used for storing and transporting data in other types of applications, making it a versatile format for data interchange.
Comparison with XML[edit | edit source]
JSON and XML are both widely used for data interchange on the web. JSON, however, is generally considered easier to read and write and less verbose than XML. JSON's lightweight nature makes it faster to parse and generate, leading to its widespread adoption, especially in web applications.
Security Considerations[edit | edit source]
While JSON is a powerful tool for data interchange, it is important to ensure that JSON data is properly validated and sanitized to prevent security vulnerabilities, such as injection attacks. When using JSONP, additional care must be taken to ensure the security of the data being transmitted, as it involves executing script received from a server.
See Also[edit | edit source]
Search WikiMD
Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD
WikiMD's Wellness Encyclopedia |
Let Food Be Thy Medicine Medicine Thy Food - Hippocrates |
Translate this page: - East Asian
中文,
日本,
한국어,
South Asian
हिन्दी,
தமிழ்,
తెలుగు,
Urdu,
ಕನ್ನಡ,
Southeast Asian
Indonesian,
Vietnamese,
Thai,
မြန်မာဘာသာ,
বাংলা
European
español,
Deutsch,
français,
Greek,
português do Brasil,
polski,
română,
русский,
Nederlands,
norsk,
svenska,
suomi,
Italian
Middle Eastern & African
عربى,
Turkish,
Persian,
Hebrew,
Afrikaans,
isiZulu,
Kiswahili,
Other
Bulgarian,
Hungarian,
Czech,
Swedish,
മലയാളം,
मराठी,
ਪੰਜਾਬੀ,
ગુજરાતી,
Portuguese,
Ukrainian
Medical Disclaimer: WikiMD is not a substitute for professional medical advice. The information on WikiMD is provided as an information resource only, may be incorrect, outdated or misleading, and is not to be used or relied on for any diagnostic or treatment purposes. Please consult your health care provider before making any healthcare decisions or for guidance about a specific medical condition. WikiMD expressly disclaims responsibility, and shall have no liability, for any damages, loss, injury, or liability whatsoever suffered as a result of your reliance on the information contained in this site. By visiting this site you agree to the foregoing terms and conditions, which may from time to time be changed or supplemented by WikiMD. If you do not agree to the foregoing terms and conditions, you should not enter or use this site. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.
Contributors: Prab R. Tumpati, MD