Class JSON
java.lang.Object
smile.io.JSON
Reads JSON datasets. No nested objects are currently allowed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumJSON files in single-line or multi-line mode. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the charset.inferSchema(BufferedReader reader, int limit) Infer the schema from the top n rows.Sets the file mode (single-line or multi-line).read(BufferedReader reader, int limit) Reads a limited number of records from a JSON file.Reads a JSON file.Reads a JSON file.Reads a JSON file.Reads a JSON file.schema(StructType schema) Sets the schema.
-
Constructor Details
-
JSON
public JSON()Constructor.
-
-
Method Details
-
schema
Sets the schema.- Parameters:
schema- the data schema.- Returns:
- this object.
-
charset
-
mode
-
read
Reads a JSON file.- Parameters:
path- the input file path.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.
-
read
Reads a JSON file.- Parameters:
path- the input file path.limit- the number of records to read.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.
-
read
Reads a JSON file.- Parameters:
path- the input file path.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.URISyntaxException- when the file path syntax is wrong.
-
read
Reads a JSON file.- Parameters:
path- the input file path.limit- the number of records to read.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.URISyntaxException- when the file path syntax is wrong.
-
read
Reads a limited number of records from a JSON file.- Parameters:
reader- the file reader.limit- the number of records to read.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.
-
inferSchema
Infer the schema from the top n rows.- Infer type of each row.
- Merge row types to find common type
- String type by default.
- Parameters:
reader- the file reader.limit- the number of records to read.- Returns:
- the data frame.
- Throws:
IOException- when fails to read the file.
-