Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-8656

Improve stout JSON -> protobuf message conversion to handle more valid JSONs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.6.0
    • None
    • None
    • Mesosphere Sprint 76
    • 2

    Description

      The followings are valid in JSON which can be successfully parsed by Google's protobuf utility function JsonStringToMessage() but can NOT be parsed our stout, i.e., call JSON::parse() to convert the JSON to a stout JSON object and then call protobuf::parse() to parse the JSON object to a protobuf message.

      "int32": "-2147483647"
      "int64": "-9223372036854775807"
      "bool": "true"
      

      The second step (protobuf::parse()) will fail with an error like this:

      Not expecting a JSON string for field 'int32'
      

      This error comes from Try<Nothing> operator()(const JSON::String& string) which currently can only convert JSON::String to protobuf string/bytes/enum, so we need to enhance it to be able to convert JSON::String to bools and integers.

      What we can parse currently are:

      "int32": -2147483647
      "int64": -9223372036854775807
      "bool": true

      We should make the behavior of our stout JSON -> protobuf conversion consistent with Google's.

      Attachments

        Activity

          People

            qianzhang Qian Zhang
            qianzhang Qian Zhang
            Benjamin Mahler Benjamin Mahler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: