FJSONPARSER
Parses and loads a JSON file. This file can contain either repeated JSON data objects (including nested maps), or an outer list of JSON elements. For a flex table, the parser stores the JSON data in a single-value VMap. For a hybrid or columnar table, the parser loads data directly in any table column with a column name that matches a key in the JSON source data.
Parameters
flatten_maps
|
BOOLEAN |
[Optional] Flattens sub-maps within the JSON data, separating map levels with a period ( Default value: |
flatten_arrays
|
BOOLEAN |
[Optional] Converts lists to sub-maps with integer keys. Lists are not flattened by default. Default value: |
reject_on_duplicate
|
BOOLEAN |
[Optional] Specifies whether to ignore duplicate records ( Default value: |
reject_on_empty_key
|
BOOLEAN |
[Optional] Rejects any row containing a key without a value ( Default value: |
omit_empty_keys
|
BOOLEAN |
[Optional] Omits any key from the load data that does not have a value ( Default value: |
record_terminator
|
STRING |
[Optional] When set, any invalid JSON records are skipped and parsing continues with the next record. Records must be terminated uniformly. For example, if your input file has JSON records terminated by newline characters, specify When you do not use a Default value: |
reject_on_materialized_type_error
|
BOOLEAN |
[Optional] Rejects a data row that contains a materialized column value that cannot be coerced into a compatible data type ( Default value: |
start_point
|
CHAR |
[Optional] Specifies the name of a key in the JSON load data at which to begin parsing. The parser ignores all data before the Default value: none |
start_point_occurrence
|
INTEGER |
[Optional] Indicates the nth occurrence of the value you specify with Default value: |
suppress_nonalphanumeric_key_chars
|
BOOLEAN |
[Optional] Suppresses non-alphanumeric characters in JSON key values. The parser replaces these characters with an underscore ( Default value: |
key_separator
|
CHAR |
[Optional] Specifies a non-default character for the parser to use when concatenating key names. Default value: |
Examples
Load JSON Data Without Optional Parameters
- Create a flex table,
super
, with two columns,age
andname
: - Enter values using the
fjsonparser()
, and query the results:
=> create table super(age int, name varchar); CREATE TABLE
=> copy super from stdin parser fjsonparser(); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself. >> {"age": 5, "name": "Tim"} >> {"age": 3} >> {"name": "Fred"} >> {"name": "Bob", "age": 10} >> \. => select * from super; age | name -----+------ | Fred 10 | Bob 5 | Tim 3 | (4 rows)
For other examples, see Loading JSON Data.