【发布时间】:2022-12-03 16:30:48
【问题描述】:
上下文:我正在尝试解析this issue。
换句话说,JSON 字符串有一个 NormalizeJsonString()(有关更多上下文,请参阅 this:
// Takes a value containing JSON string and passes it through
// the JSON parser to normalize it, returns either a parsing
// error or normalized JSON string.
func NormalizeJsonString(jsonString interface{}) (string, error) {
允许具有以下代码:
return structure.NormalizeJsonString(old) == structure.NormalizeJsonString(new)
但它不适用于原型文件的字符串(所有原型文件都保证只有一个消息定义)。例如,我可以看到:
syntax = "proto3";
- package bar.proto;
+ package bar.proto;
option java_outer_classname = "FooProto";
message Foo {
...
- int64 xyz = 3;
+ int64 xyz = 3;
某些 Go SDK 中是否有 NormalizeProtoString 可用?我找到了MessageDifferencer,但它只在 C++ 中。我考虑的另一个选择是用一个空格替换所有新行/空格组,但这有点老套。
【问题讨论】:
标签: go protocol-buffers