Reranko05 commented on code in PR #50937:
URL: https://github.com/apache/arrow/pull/50937#discussion_r3842353236


##########
cpp/src/arrow/integration/json_internal.cc:
##########
@@ -880,48 +880,47 @@ Result<TimeUnit::type> GetUnitFromString(const 
std::string& unit_str) {
 }
 
 template <typename IntType = int>
-Result<IntType> GetMemberInt(const RjObject& obj, const std::string& key) {
-  const auto& it = obj.FindMember(key);
-  RETURN_NOT_INT(key, it, obj);
-  return static_cast<IntType>(it->value.GetInt64());
+Result<IntType> GetMemberInt(const JsonObject& obj, std::string_view key) {
+  ARROW_ASSIGN_OR_RAISE(
+      auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get 
JSON field"));
+  ARROW_ASSIGN_OR_RAISE(auto integer, internal::ResolveSimdjsonResult(
+                                          value.get_int64(), "field was not an 
integer"));
+  return static_cast<IntType>(integer);
 }
 
-Result<bool> GetMemberBool(const RjObject& obj, const std::string& key) {
-  const auto& it = obj.FindMember(key);
-  RETURN_NOT_BOOL(key, it, obj);
-  return it->value.GetBool();
+Result<bool> GetMemberBool(const JsonObject& obj, std::string_view key) {
+  ARROW_ASSIGN_OR_RAISE(
+      auto value, internal::ResolveSimdjsonResult(obj[key], "Failed to get 
JSON field"));
+  return internal::ResolveSimdjsonResult(value.get_bool(), "field was not a 
boolean");
 }
 
-Result<std::string> GetMemberString(const RjObject& obj, const std::string& 
key) {
-  const auto& it = obj.FindMember(key);
-  RETURN_NOT_STRING(key, it, obj);
-  return it->value.GetString();
+Result<std::string> GetMemberString(const JsonObject& obj, std::string_view 
key) {

Review Comment:
   I kept the helper returning `std::string`, as several callers require an 
owning string, but made the conversion from simdjson's `std::string_view` 
explicit.



-- 
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]

Reply via email to