2

I have defined a proto with an array(repeated) and redefine it later to a map after some years. How to migrate the jsons written with previous defined proto format to the new redefined format?

PS : I don't want the users to manually change it

Example : The following is what I have defined in previous version

syntax = "proto3";
repeated Foo models = 1;
message Foo {
  string id = 1;
  string module = 2;
  string pattern = 3;
}

I redefine it to the following :

syntax = "proto3";
map<string,Foo> models = 1;
message Foo {
  string module = 1;
  string pattern = 2;
}
Joakim Danielson
  • 43,251
  • 5
  • 22
  • 52
Lakshmi C
  • 31
  • 8
  • Your proposed change violates two of the best-practice rules from the official [docs](https://protobuf.dev/programming-guides/dos-donts/): 1) don't re-use a tag number and 2) don't change the type of a field. As such, I don't think there are going to be many ways to accomplish this cleanly – Addison Klinke Apr 28 '23 at 18:05

0 Answers0