JSON Object#
- group json_object
Functions
-
std::unique_ptr<cudf::column> get_json_object(cudf::strings_column_view const &col, cudf::string_scalar const &json_path, get_json_object_options options = get_json_object_options{}, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#
Apply a JSONPath string to all rows in an input strings column.
Applies a JSONPath string to an incoming strings column where each row in the column is a valid json string. The output is returned by row as a strings column.
https://tools.ietf.org/id/draft-goessner-dispatch-jsonpath-00.html Implements only the operators: $ . [] *
- Throws:
std::invalid_argument – if provided an invalid operator or an empty name
- Parameters:
col – The input strings column. Each row must contain a valid json string
json_path – The JSONPath string to be applied to each row
options – Options for controlling the behavior of the function
stream – CUDA stream used for device memory operations and kernel launches
mr – Resource for allocating device memory
- Returns:
New strings column containing the retrieved json object strings
-
class get_json_object_options#
- #include <json.hpp>
Settings for
get_json_object()
.Public Functions
-
explicit get_json_object_options() = default#
Default constructor.
-
inline bool get_allow_single_quotes() const#
Returns true/false depending on whether single-quotes for representing strings are allowed.
- Returns:
true if single-quotes are allowed, false otherwise.
-
inline bool get_strip_quotes_from_single_strings() const#
Returns true/false depending on whether individually returned string values have their quotes stripped.
When set to true, if the return value for a given row is an individual string (not an object, or an array of strings), strip the quotes from the string and return only the contents of the string itself. Example:
With strip_quotes_from_single_strings OFF: Input = {"a" : "b"} Query = $.a Output = "b" With strip_quotes_from_single_strings ON: Input = {"a" : "b"} Query = $.a Output = b
- Returns:
true if individually returned string values have their quotes stripped.
-
inline bool get_missing_fields_as_nulls() const#
Whether a field not contained by an object is to be interpreted as null.
When set to true, if an object is queried for a field it does not contain, a null is returned.
With missing_fields_as_nulls OFF: Input = {"a" : [{"x": "1", "y": "2"}, {"x": "3"}]} Query = $.a[*].y Output = ["2"] With missing_fields_as_nulls ON: Input = {"a" : [{"x": "1", "y": "2"}, {"x": "3"}]} Query = $.a[*].y Output = ["2", null]
- Returns:
true if missing fields are interpreted as null.
-
inline void set_allow_single_quotes(bool _allow_single_quotes)#
Set whether single-quotes for strings are allowed.
- Parameters:
_allow_single_quotes – bool indicating desired behavior.
-
inline void set_strip_quotes_from_single_strings(bool _strip_quotes_from_single_strings)#
Set whether individually returned string values have their quotes stripped.
- Parameters:
_strip_quotes_from_single_strings – bool indicating desired behavior.
-
inline void set_missing_fields_as_nulls(bool _missing_fields_as_nulls)#
Set whether missing fields are interpreted as null.
- Parameters:
_missing_fields_as_nulls – bool indicating desired behavior.
-
explicit get_json_object_options() = default#
-
std::unique_ptr<cudf::column> get_json_object(cudf::strings_column_view const &col, cudf::string_scalar const &json_path, get_json_object_options options = get_json_object_options{}, rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref())#