Add a minireflect based json parser.

This parser takes decent json and parses it into a flatbuffer.  The
standard library for flatbuffers needs the full fbs definitions for all
the flatbuffers to do this job.

And add a flatbuffer to JSON function.

Change-Id: Ibc6dcd3fcbd7ac9cf9121d8258d1613d8d20661c
diff --git a/third_party/jsont/BUILD b/third_party/jsont/BUILD
new file mode 100644
index 0000000..dc1d03d
--- /dev/null
+++ b/third_party/jsont/BUILD
@@ -0,0 +1,28 @@
+licenses(["notice"])
+
+cc_library(
+    name = "jsont",
+    srcs = [
+        "jsont.c",
+    ],
+    hdrs = [
+        "jsont.h",
+    ],
+    includes = ["."],
+    visibility = ["//visibility:public"],
+)
+
+cc_test(
+    name = "jsont_test",
+    srcs = ["test/test_tokenizer.c"],
+    copts = [
+        "-Wno-unused-parameter",
+        "-Wno-unused-variable",
+    ] + select({
+        "@//tools:cpu_roborio": [
+            "-Wno-unused-but-set-variable",
+        ],
+        "//conditions:default": [],
+    }),
+    deps = [":jsont"],
+)
diff --git a/third_party/jsont/jsont.c b/third_party/jsont/jsont.c
index 5863c7a..b318494 100644
--- a/third_party/jsont/jsont.c
+++ b/third_party/jsont/jsont.c
@@ -74,7 +74,7 @@
   for (size_t i = 0; i != len; ++i) {
     uint8_t b = bytes[i];
     int digit = (b > '0'-1 && b < 'f'+1) ? kHexValueTable[b-'0'] : -1;
-    if (b == -1 || // bad digit
+    if (b == 0xff || // bad digit
         (value > cutoff) || // overflow
         ((value == cutoff) && (digit > cutoff_digit)) ) {
       return ULONG_MAX;
@@ -172,9 +172,10 @@
       (memcmp((const void*)ctx->value_buf.data,
         (const void*)bytes, length) == 0);
   } else {
-    return (ctx->input_buf_value_end - ctx->input_buf_value_start == length) &&
-      (memcmp((const void*)ctx->input_buf_value_start,
-        (const void*)bytes, length) == 0);
+    return (ctx->input_buf_value_end - ctx->input_buf_value_start ==
+            (ssize_t)length) &&
+           (memcmp((const void *)ctx->input_buf_value_start,
+                   (const void *)bytes, length) == 0);
   }
 }