How to convert bpmn into json format.?

Here i have taken a html file in which i will bind the diagram.

    <div class="canvas diagram-wrapper col-sm-12" style="height: 800px; width : 1000px;">
        <div id="js-canvas" style="height: 800px; width : 1000px;">

And here i have written a js code to bind the required shape.

var console = document.querySelector('#js-console');
        var diagramXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<definitions xmlns=\"\"\r\n             xmlns:bpmndi=\"\"\r\n             xmlns:omgdc=\"\"\r\n             xmlns:omgdi=\"\"\r\n             xmlns:xsi=\"\"\r\n             expressionLanguage=\"\"\r\n             typeLanguage=\"\"\r\n             targetNamespace=\"\"\r\n             xsi:schemaLocation=\"\">\r\n<process id=\"sid-C3803939-0872-457F-8336-EAE484DC4A04\" isClosed=\"false\" isExecutable=\"false\" name=\"Customer\" processType=\"None\">\r\n    <startEvent id=\"sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138\" name=\"Start\">\r\n        </startEvent>\r\n</process>\r\n<bpmndi:BPMNDiagram id=\"sid-74620812-92c4-44e5-949c-aa47393d3830\">\r\n    <bpmndi:BPMNPlane bpmnElement=\"sid-c0e745ff-361e-4afb-8c8d-2a1fc32b1424\" id=\"sid-cdcae759-2af7-4a6d-bd02-53f3352a731d\">\r\n  <bpmndi:BPMNShape bpmnElement=\"sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138\" id=\"sid-D7F237E8-56D0-4283-A3CE-4F0EFE446138_gui\">\r\n            <omgdc:Bounds height=\"30.0\" width=\"30.0\" x=\"150.0\" y=\"165.0\"/>\r\n          </bpmndi:BPMNShape>\r\n      </bpmndi:BPMNPlane>\r\n    </bpmndi:BPMNDiagram>\r\n</definitions>\r\n\r\n";
        var viewer = new BpmnJS({
            container: document.querySelector('#js-canvas'),
            height: 700
        viewer.importXML(diagramXML, function (err) {
            var eventBus = viewer.get('eventBus');
            // you may hook into any of the following events
            var events = [

On click of a save button i have to save diagram in json format.
How can I do that I am not getting any valid solution. I tried almost all examples from forum. Just give me the solution of save method.

I have to write the saving code here in this below method.
I am removing my logic as its not working.

$("#btn_Save").click(function ()
'Code to convert that bpmn diagram into json format.?

Thank in advance.

There is no standard way to export your diagram into a JSON representative, since there no official specification for it. Internally, we parse the XML into a javascript object tree via bpmn-moddle. You can read more about it in our walkthrough (Chapter: BPMN Meta-Model (bpmn-moddle)).