You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/24 14:54:04 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #14486: ARROW-18144: [C++] Improve JSONTypeError error message in testing

pitrou commented on code in PR #14486:
URL: https://github.com/apache/arrow/pull/14486#discussion_r1003415982


##########
cpp/src/arrow/ipc/json_simple.cc:
##########
@@ -63,10 +63,11 @@ using ::arrow::internal::checked_pointer_cast;
 namespace {
 
 constexpr auto kParseFlags = rj::kParseFullPrecisionFlag | rj::kParseNanAndInfFlag;
-
+constexpr std::array<const char*, 7> kJsonTypeNames{"null",  "false",  "true",  "object",
+                                                    "array", "string", "number"};

Review Comment:
   1. Let's keep it simple and make it a `std::vector`? (we don't care whether it can be made `constexpr` or not)
   2. Is this robust against potential changes in enumeration order? Perhaps it would be better to instead make it a helper function:
   ```c++
   const char* JSONTypeName(rj::Type json_type) {
     switch (json_type) {
       case rj::kNullType: return "null";
       // etc.
     }
   }
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org