def ToJSon(self, columns_order=None, order_by=()):
encoded_response_str = DataTableJSONEncoder().encode(self._ToJSonObj(columns_order, order_by))<EOL>if not isinstance(encoded_response_str, str):<EOL><INDENT>return encoded_response_str.encode("<STR_LIT:utf-8>")<EOL><DEDENT>return encoded_response_str<EOL>
Returns a string that can be used in a JS DataTable constructor.

        This method writes a JSON string that can be passed directly into a Google
        Visualization API DataTable constructor. Use this output if you are
        hosting the visualization HTML on your site, and want to code the data
        table in Python. Pass this string into the
        google.visualization.DataTable constructor, e.g,:
          ... on my page that hosts my visualization ...
          google.setOnLoadCallback(drawTable);
          function drawTable() {
            var data = new google.visualization.DataTable(_my_JSon_string, 0.6);
            myTable.draw(data);
          }

        Args:
          columns_order: Optional. Specifies the order of columns in the
                         output table. Specify a list of all column IDs in the order
                         in which you want the table created.
                         Note that you must list all column IDs in this parameter,
                         if you use it.
          order_by: Optional. Specifies the name of the column(s) to sort by.
                    Passed as is to _PreparedData().

        Returns:
          A JSon constructor string to generate a JS DataTable with the data
          stored in the DataTable object.
          Example result (the result is without the newlines):
           {cols: [{id:"a",label:"a",type:"number"},
                   {id:"b",label:"b",type:"string"},
                  {id:"c",label:"c",type:"number"}],
            rows: [{c:[{v:1},{v:"z"},{v:2}]}, c:{[{v:3,f:"3$"},{v:"w"},null]}],
            p:    {'foo': 'bar'}}

        Raises:
          DataTableException: The data does not match the type.