taepper commented on code in PR #50653:
URL: https://github.com/apache/arrow/pull/50653#discussion_r3663507210
##########
cpp/src/arrow/json/from_string.cc:
##########
@@ -83,15 +83,65 @@ const char* JsonTypeName(sj::json_type type) {
}
}
-Status JSONTypeError(const char* expected_type,
- simdjson::simdjson_result<sj::json_type>
json_type_result) {
- sj::json_type json_type;
- if (std::move(json_type_result).get(json_type) != simdjson::SUCCESS) {
- return Status::Invalid("Expected ", expected_type,
- " or null, got malformed JSON value");
+template <typename>
+inline constexpr bool kAlwaysFalse = false;
+
+template <typename SimdjsonClass>
+const char* JsonTypeName() {
+ if constexpr (std::is_same_v<SimdjsonClass, sj::array>) {
+ return "array";
+ } else if constexpr (std::is_same_v<SimdjsonClass, sj::object>) {
+ return "object";
+ } else if constexpr (std::is_same_v<SimdjsonClass, std::string_view>) {
+ return "string";
+ } else if constexpr (std::is_same_v<SimdjsonClass, bool>) {
+ return "boolean";
+ } else if constexpr (std::is_same_v<SimdjsonClass, std::monostate>) {
Review Comment:
`std::monostate`
We probably want to add a typedef for this (if we want to keep this at
all?). Alternatively, we could check the `null` case also always by hand
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]