Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

RawJSON (.json)

BackgroundBackground

    MIME type: application/json.
    Data interchange format.
    RawJSON supports full JSON syntax but uses a specific interpretation.
    RawJSON identifies JSON objects with Wolfram Language associations.
    JSON is commonly used in web programming.
    JSON is an acronym derived from JavaScript Object Notation.
    JSON is based on a subset of the JavaScript programming language.
    Plain text format.
    JSON was developed in 2001.
    JSON is published as RFC 4627.

Import and ExportImport and Export

  • Import["file","RawJSON"] imports a JSON file as a combination of nested lists and associations.
  • ImportString["string","RawJSON"] imports a JSON string.
  • Export["file",expr,"RawJSON"] exports a combination of nested lists and associations to a JSON file.
  • ExportString[expr,"RawJSON"] exports to a JSON string.
  • See the main function pages for full general information on Import and Export.
  • ImportString and ExportString support the RawJSON data format.

ElementsElements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation element:
  • "Data"contents of a JSON file as nested lists or associations
  • Import by default uses the element.
  • The "RawJSON" format identifies JSON objects of the form with associations of the form in the Wolfram Language.
  • "RawJSON" identifies JSON lists with Wolfram Language lists .
  • Strings in the Wolfram Language are represented in RawJSON as UTF-8 strings, escaped as required by the JSON standard.
  • Numbers where scientific notation is used are given in RawJSON in E notation.
  • The symbols True and False are represented in RawJSON as the values and .
  • The symbol Null is represented as the JSON value .

OptionsOptions

  • Export options:
  • "Compact"Falsewhether to omit line breaks and tabs

ExamplesExamplesopen allclose all

Basic Examples  (6)Basic Examples  (6)

Import a JSON list:

In[1]:=
Click for copyable input
Out[1]=

Give a string consisting of a JSON object:

In[1]:=
Click for copyable input
Out[1]=

Importing this string gives an association:

In[2]:=
Click for copyable input
Out[2]=

Import the contents of a JSON file:

In[1]:=
Click for copyable input
Out[1]=

Import a URL:

In[1]:=
Click for copyable input
Out[1]=

Export an expression to a JSON string:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Export a list of chemical elements and their properties to a JSON file:

In[1]:=
Click for copyable input
Out[1]=

Export to a string:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2015
(10.2)