Skip to content

Conversation

@wking
Copy link

@wking wking commented Sep 26, 2015

I thought it would be easier to judge JSON compatibility if I filled
in a few more fields. The version addition is pretty minor, but I'm
having trouble getting the process fields to serialize. With
7831505, I get:

$ make
go run ./example.go
{
  "spec": {
    "version": "0.1.0",
    "platform": {
      "os": "linux",
      "arch": "x86_64"
    },
    "process": {
      "terminal": true,
      "user": {
        "type": 1
      },
      "args": [
        "sh"
      ],
      "env": [
        "TERM=linux"
      ],
      "cwd": "/root"
    }
  }
}

The extension fields aren't serialized, and I expect that has
something to do with:

$ grep -B4 -A2 'extension.*json' go/config.pb.go 
type User struct {
        // Type so that receivers of this message can `switch` for the fields
        // expected
        Type             *PlatformType             `protobuf:"varint,1,opt,name=type,enum=oci.PlatformType" json:"type,omitempty"`
        XXX_extensions   map[int32]proto.Extension `json:"-"`
        XXX_unrecognized []byte                    `json:"-"`
}

I'll take a stab at the protobuf3 branch and see if I have better luck
there.

Feel free to pull these commits into your protobuf branch or not as
you see fit.

To match the example in config.md.

Signed-off-by: W. Trevor King <[email protected]>
To match the example in config.md.

Signed-off-by: W. Trevor King <[email protected]>
vbatts pushed a commit that referenced this pull request Apr 12, 2016
Don't use strings when you can use dictionaries/objects. JSON objects are trivial to parse and manipulate, unlike strings. String parsing is the #1 cause of security bugs, so if it can be trivially avoided, then why not ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant