JSON

From WikiMD's Food, Medicine & Wellness Encyclopedia

JSON vector logo
Douglas Crockford

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]

Wiki.png

Navigation: Wellness - Encyclopedia - Health topics - Disease Index‏‎ - Drugs - World Directory - Gray's Anatomy - Keto diet - Recipes

Search WikiMD


Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro) available.
Advertise on WikiMD

WikiMD is not a substitute for professional medical advice. 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