Image

JSON, which stands for JavaScript Object Notation, is a text-based data format used for structuring data. JSON is a competitor to XML.

BEGINNER

⇒ Code Examples

→ You must be bilingual (Fr/En). Code examples are in English.

→ Let's start with very simple codes. The more you progress, page after page, the more sophisticated the scripts will be. However, you must go over 30 to 40 pages per level, before moving on to the next step...

→ In order to evaluate your codes, click on the icon on the left at the bottom of the page (gears), then choose a compiler from the list that will be open in another tab. Finally, test your work.

NOW REPRODUCE AND IMMERSE YOURSELF!

C 0001 - Welcome !
Reproduce this code (do not copy and paste!).

<!DOCTYPE html>
<html>
<body>
<h2>Fond of Code</h2>
<p id="example"></p>
<script>
let text = '{"message":[' +
'{"textOne":"invite","lastName":"you..." },' +
'{"textOne":"welcome","lastName":"you !" },' +
'{"textOne":"teach","lastName":"you !" }]}';
const obj = JSON.parse(text);
document.getElementById("example").innerHTML =
obj.message[1].textOne + " " + obj.message[1].lastName;
</script>
</body>
</html>
C 0002 - Welcome again !
Reproduce this code (do not copy and paste!).

<!DOCTYPE html>
<html>
<body>
<h2>Fond of Code</h2>
<p id="example"></p>
<script>
let text = '{"message":[' +
'{"textOne":"invite","lastName":"you..." },' +
'{"textOne":"welcome","lastName":"you !" },' +
'{"textOne":"teaches","lastName":"you !" }]}';
const obj = JSON.parse(text);
document.getElementById("example").innerHTML =
obj.message[2].textOne + " " + obj.message[2].lastName;
</script>
</body>
</html>
Image

CHOISISSEZ VOTRE COMPILATEUR

Reproduisez ce code, en choisissant l'un des compilateurs ci-dessous (ne copiez-collez pas ! Ce serait trop facile). Tous ont la même fonction, choisissez-en un en tenant simplement compte de vos préférences.

Lorsque vous copiez votre code, remplacez le code existant (par défaut) figurant déjà dans le compilateur, par le vôtre.

Attention ! Pour certains de ces compilateurs, vous devez vous-même choisir le langage de programmation, dans le menu qui vous est alors proposé. Bien évidemment, n'oubliez pas de cliquer sur RUN !

All about JSON

Code

Tools/Methodologies

Info+

» Creation Date: 2001
* Created by Douglas Crockford
* Developed by Douglas Crockford
* Open Format
* JavaScript-based

News

The comments you leave us are systematically subject to rigorous moderation. Incivility and slander, threats, intimidation of all kinds, more generally all gratuitous verbal violence, or the dissemination of unverified information... are not tolerated. We also reserve the right to publish only comments which effectively advance the debate and allow a better understanding of the subject covered by the article presented on this page (as well as all its ramifications) and this, whatever its overall content.

Image

Fond of Code TM © ®
All rights reserved - Protected Trademark/Logo (INPI)

Legal structures based in
Nice - FRANCE

Montreal - Canada
By appointment

SIRET: 41138921600028 (France)
Inc. : 661515-5 (Canada, Qc.)
Official resumption in France : March 2025
Beta version of the website : May 2024
Implementation : July 2024
Launch of initial activity : 1996 (Europe and North America)
New version of the website : April 2025

Fond of Code official launch : May 2025

Image
Image