JSON
ParseFile
read JSON data from a file
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
ParseFile(source, opts)
source
-
string; file or URL to read from
opts
(optional) options as specified below
array : list or Array
Specifies the data structure to use for parsed data corresponding to JSON arrays (sequential data delimited with square brackets). With array=list (the default), a JSON array is encoded as a list; with array=Array, it is encoded as an Array.
object : one of table, record, or DataSeries
Specifies the data structure to use for parsed data corresponding to JSON objects (collections of key/value pairs delimited with curly braces).
With object=table (the default), an object is encoded as table; with object=record, it is encoded as a record; with object=DataSeries, it is encoded as a DataSeries.
output : one of table, record, or DataSeries
A legacy alias for the object option.
ParseFile(source) reads JSON data from the file or URL source.
If source is a file, it is closed after it is read.
Parse an input JSON file to a Maple table
address≔FileTools:-JoinPath⁡example/address.json,base=datadir
address≔/maple/cbat/active/268316/data/example/address.json
JSON:-ParseFile⁡address
table⁡phoneNumbers=table⁡type=local,number=+1 (519) 747-2373,table⁡type=tollfree,number=+1 (800) 267-6583,table⁡type=fax,number=+1 (519) 747-5284,address=table⁡country=Canada,city=Waterloo,postalCode=N2V 1K8,streetAddress=615 Kumpf Drive,province=ON,founded=1988,companyName=Maplesoft
Parse the same input JSON file to a Maple record
JSON:-ParseFile⁡address,object=record
Recordpacked⁡companyName=Maplesoft,founded=1988,address=Recordpacked⁡...,phoneNumbers=Recordpacked⁡...,Recordpacked⁡...,Recordpacked⁡...
The JSON[ParseFile] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The JSON[ParseFile] command was updated in Maple 2022.
The array and object options were introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
See Also
JSON[ParseString]
JSON[ToString]
Download Help Document