I need to save Google protobuf IMessage object into json file, using C#. here is sample code:
using (var input = File.OpenRead(protodatFile))
{
string jsonString = null;
message.MergeFrom(input); //read message from protodat file
JsonFormatter formater = new JsonFormatter(
new JsonFormatter.Settings(false));
jsonString = formatter.Format(message);
System.IO.File.WriteAllText(jsonFile, jsonString);
}
This uses the JsonFormatter
from the Google Protobuf library.
The problem: all json content is stored in one line. when file is quite big(>50 MB) it is hard to open/view in text editor.
What is the best way to make indented jsonFile here?