json.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
9 #include <cudf/utilities/export.hpp>
11 
12 namespace CUDF_EXPORT cudf {
13 
25  // allow single quotes to represent strings in JSON
26  bool allow_single_quotes = false;
27 
28  // individual string values are returned with quotes stripped.
29  bool strip_quotes_from_single_strings = true;
30 
31  // Whether to return nulls when an object does not contain the requested field.
32  bool missing_fields_as_nulls = false;
33 
34  public:
38  explicit get_json_object_options() = default;
39 
46  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_allow_single_quotes() const
47  {
48  return allow_single_quotes;
49  }
50 
75  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_strip_quotes_from_single_strings() const
76  {
77  return strip_quotes_from_single_strings;
78  }
79 
101  [[nodiscard]] CUDF_HOST_DEVICE inline bool get_missing_fields_as_nulls() const
102  {
103  return missing_fields_as_nulls;
104  }
105 
111  void set_allow_single_quotes(bool _allow_single_quotes)
112  {
113  allow_single_quotes = _allow_single_quotes;
114  }
115 
121  void set_strip_quotes_from_single_strings(bool _strip_quotes_from_single_strings)
122  {
123  strip_quotes_from_single_strings = _strip_quotes_from_single_strings;
124  }
125 
131  void set_missing_fields_as_nulls(bool _missing_fields_as_nulls)
132  {
133  missing_fields_as_nulls = _missing_fields_as_nulls;
134  }
135 };
136 
155 std::unique_ptr<cudf::column> get_json_object(
156  cudf::strings_column_view const& col,
157  cudf::string_scalar const& json_path,
161  // end of doxygen group
163 } // namespace CUDF_EXPORT cudf
Settings for get_json_object().
Definition: json.hpp:24
CUDF_HOST_DEVICE bool get_allow_single_quotes() const
Returns true/false depending on whether single-quotes for representing strings are allowed.
Definition: json.hpp:46
void set_strip_quotes_from_single_strings(bool _strip_quotes_from_single_strings)
Set whether individually returned string values have their quotes stripped.
Definition: json.hpp:121
void set_allow_single_quotes(bool _allow_single_quotes)
Set whether single-quotes for strings are allowed.
Definition: json.hpp:111
get_json_object_options()=default
Default constructor.
void set_missing_fields_as_nulls(bool _missing_fields_as_nulls)
Set whether missing fields are interpreted as null.
Definition: json.hpp:131
CUDF_HOST_DEVICE bool get_strip_quotes_from_single_strings() const
Returns true/false depending on whether individually returned string values have their quotes strippe...
Definition: json.hpp:75
CUDF_HOST_DEVICE bool get_missing_fields_as_nulls() const
Whether a field not contained by an object is to be interpreted as null.
Definition: json.hpp:101
An owning class to represent a string in device memory.
Definition: scalar.hpp:411
Given a column-view of strings type, an instance of this class provides a wrapper on this compound co...
APIs for querying the default CUDA stream and per-thread default stream status.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
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.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
APIs for getting and setting the current device memory resource.
cuDF interfaces
Definition: host_udf.hpp:26
Class definition for cudf::strings_column_view.
#define CUDF_HOST_DEVICE
Indicates that the function or method is usable on host and device.
Definition: types.hpp:21