Skip to content

decode to json from command line #4024

@KantarBruceAdams

Description

@KantarBruceAdams

Bug: The man page does not state what format is used by the --decode and --encode options
Feature request: Add an option to decode directly to json.

Looking for a way to decode a message into json from the command line I stumbled upon:

https://stackoverflow.com/questions/34952811/is-there-a-definitive-nix-command-line-tool-for-inspecting-protocol-buffers

which mentions the --decode option which at first sight appears to be just what I was looking for.
However the output format is not in fact json but something called "text format" which is undocumented (see #3755).

My use case is that I am writing test cases to check the output of programs that send messages encoded using protocol buffers. I want to convert them to some format that can be analysed easily and add test assertions.
E.g.

ACTUAL=protoc --decode .... | jq .getSomeField
assertEqual "expected foo" "foo" "$ACTUAL"

Metadata

Metadata

Assignees

Labels

c++enhancementinactiveDenotes the issue/PR has not seen activity in the last 90 days.protoc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions