Skip to content

Instantly share code, notes, and snippets.

@xtrmstep
Created February 8, 2018 17:58
Show Gist options
  • Save xtrmstep/292c9db972072d4a63b4ce00262c2b49 to your computer and use it in GitHub Desktop.
Save xtrmstep/292c9db972072d4a63b4ce00262c2b49 to your computer and use it in GitHub Desktop.
Get object dump in JSON with Google ProtocolBuffers
public static string ToJson(this object obj)
{
var messageLite = obj as IMessageLite;
if (messageLite != null)
return Google.ProtocolBuffers.Extensions.ToJson(messageLite);
return JsonConvert.SerializeObject(obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment