Closed Alex-CodeLab closed 6 years ago
nevermind..
from google.protobuf.json_format import MessageToJson
seems to work just fine
@FeedTheWeb glad you figured it out - I've been debating weather to convert everything to list/dict (native python types) vs keeping the responses in the form of the grpc classes.
I too have been converting to dict a lot so maybe I'll add an option where one can just set it and it will run MessageToJson
on all responses (where appropriate).
I think that's a good idea. The tip above helped me as well (I was trying to get network graph). But it would be easier built in.
Agree that this would be a very useful method to have. I had a look at the code and wasn't sure where to add it. Instead, perhaps it is easier to just do from google.protobuf.json_format import MessageToJson
in the main module so people can use that function easily? Or mention in the README.
Cheers for the help
import json
from google.protobuf.json_format import MessageToJson
channels = lnd.list_channels()
json.loads(MessageToJson(channels))
to get it all the way to a dict
list_invoices()
returns arpc_pb2.ListInvoiceResponse
.Is there an easy way to get this as a json or dict?