Purpose
Initialise a Mosel entity from a JSON data file.
Synopsis
procedure jsonread(fname:text|string, mosobj:*)
Arguments
fname
|
Name of a JSON file
|
mosobj
|
A Mosel entity
|
Further information
1. This procedure accepts basic types (
integer,
real,
boolean,
string), native types compatible with from/tostring (
e.g.
text or
date, they are initialised from json strings), records (only public fields of supported types are populated from the corresponding json object members), lists of compatible types (populated from json arrays) and unions. Unsupported entities are silently ignored (
e.g. sets and arrays) and entries in the JSON document that do not correspond to an expected entry are also ignored.
2. Unions have a special handling: they can be initialised with a scalar (number, boolean or string) or an object if the union itself is already a field of a record (in this case the union takes the type of the structure that includes it).
3. Although basic types are supported the routine cannot initialise a scalar of a basic type: its input parameter must be a record, a union, a variable of a native type (supporting serialisation) or a list.
4. The procedure does not reset its input parameter: in particular when initialising a list, the values from the JSON file will be appended to the existing content. Note that the special value
null from the JSON data might be applied to lists, records and unions to reset these entities.
5. An IO error will be raised if the source file cannot be accessed or if a parsing error occurs.
Related topics
Module
© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the
property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not
convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except
solely for internal evaluation purposes to determine whether to purchase a license to the software
described in this documentation, or as otherwise set forth in a written software license agreement
between you and FICO (or a FICO affiliate). Use of this documentation and the software described in
it must conform strictly to the foregoing permitted uses, and no other use is permitted.