Merge pull request #387 from haberman/json-null

JSON: Only perform multiple oneof check for non-null fields.
pull/13171/head
Joshua Haberman 4 years ago committed by GitHub
commit 0723bfa700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      bazel/workspace_deps.bzl
  2. 10
      upb/json_decode.c

@ -36,8 +36,8 @@ def upb_deps():
maybe(
http_archive,
name = "bazel_skylib",
strip_prefix = "bazel-skylib-master",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/master.tar.gz"],
strip_prefix = "bazel-skylib-main",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/main.tar.gz"],
)
maybe(

@ -939,17 +939,17 @@ static void jsondec_field(jsondec *d, upb_msg *msg, const upb_msgdef *m) {
return;
}
if (upb_fielddef_realcontainingoneof(f) &&
upb_msg_whichoneof(msg, upb_fielddef_containingoneof(f))) {
jsondec_err(d, "More than one field for this oneof.");
}
if (jsondec_peek(d) == JD_NULL && !jsondec_isvalue(f)) {
/* JSON "null" indicates a default value, so no need to set anything. */
jsondec_null(d);
return;
}
if (upb_fielddef_realcontainingoneof(f) &&
upb_msg_whichoneof(msg, upb_fielddef_containingoneof(f))) {
jsondec_err(d, "More than one field for this oneof.");
}
preserved = d->debug_field;
d->debug_field = f;

Loading…
Cancel
Save