[skottie] Json cleanup pass

Assorted Json tweaks:

  - more defensive internal object access
  - drop unneeded isObject checks
  - drop unneeded namespace
  - restrict the iterator to arrays

TBR=
Change-Id: I02f1c5d84c429cf5206bc2a0a7843097b92bac94
Reviewed-on: https://skia-review.googlesource.com/126930
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/experimental/skottie/Skottie.cpp b/experimental/skottie/Skottie.cpp
index 99549bf..0ac1b4e 100644
--- a/experimental/skottie/Skottie.cpp
+++ b/experimental/skottie/Skottie.cpp
@@ -63,7 +63,7 @@
 
 bool LogFail(const json::ValueRef& json, const char* msg) {
     const auto dump = json.toString();
-    LOG("!! %s: %s", msg, dump.c_str());
+    LOG("!! %s: %s\n", msg, dump.c_str());
     return false;
 }
 
@@ -126,9 +126,8 @@
 
     // This is more peeky than other attachers, because we want to avoid redundant opacity
     // nodes for the extremely common case of static opaciy == 100.
-    const auto& opacity = jtransform["o"];
-    if (opacity.isObject() &&
-        !opacity["a"].toDefault(true) &&
+    const auto opacity = jtransform["o"];
+    if (!opacity["a"].toDefault(true) &&
         opacity["k"].toDefault<int>(-1) == 100) {
         // Ignoring static full opacity.
         return childNode;
@@ -276,7 +275,7 @@
 sk_sp<sksg::Gradient> AttachGradient(const json::ValueRef& obj, AttachContext* ctx) {
     SkASSERT(obj.isObject());
 
-    const auto& stops = obj["g"];
+    const auto stops = obj["g"];
     if (!stops.isObject())
         return nullptr;
 
@@ -528,11 +527,8 @@
         { "tr", ShapeType::kTransform     , 0 }, // transform -> Inline handler
     };
 
-    if (!shape.isObject())
-        return nullptr;
-
-    const auto type = shape["ty"].toDefault(SkString());
-    if (type.isEmpty())
+    SkString type;
+    if (!shape["ty"].to(&type) || type.isEmpty())
         return nullptr;
 
     const auto* info = bsearch(type.c_str(),
@@ -594,7 +590,7 @@
         const auto s = jshape[jshape.size() - 1 - i];
         const auto* info = FindShapeInfo(s);
         if (!info) {
-            LogFail(s.isObject() ? s["ty"] : s, "Unknown shape");
+            LogFail(s["ty"], "Unknown shape");
             continue;
         }