Parse from base64 string via protobuf for javascript

I want to do following: feed a binary string of protobuf message encoded to base 64 in Python to server and then decode it back to entity via Protobuf for Javascript. I have the following code in view:

...
result = data_sample.SerializeToString()
result = base64.b64encode(result)
return render(request, 'pr22/index.html', {'result': result})

in template:

<script src="static/Long.min.js"></script>
<script src="static/ByteBuffer.min.js"></script>
<script src="static/ProtoBuf.min.js"></script>
<script type="text/javascript">
    var ProtoBuf = dcodeIO.ProtoBuf;
    var builder = ProtoBuf.loadProtoFile("static/schema.proto");

</script>

what's next?

Answers


Read the docs! :P

... but basically you'll want something like this:

var YourMessage = builder.build("YourMessage");
var myMessage = YourMessage.decode64("{{result|safe}}");

Need Your Help

Sitecore: How and why use Sitecore Virtual Users in CD (content Delivery)

asp.net security sitecore sitecore8

I've come across few sitecore implementations where virtual users have been used on CD (content delivery) where site has a membership (login state).

HTML Formatting in td?

javascript jquery html html-table

Currently, my jQuery AJAX call returns data to me that looks something like this: