nodes: 0, module; 1, function_definition; 2, function_name:ToJSon; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, identifier:columns_order; 13, None; 14, identifier:order_by; 15, tuple; 16, comment:"""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.
      """; 17, assignment; 18, not_operator; 19, block; 20, identifier:encoded_response_str; 21, identifier:encoded_response_str; 22, call; 23, call; 24, return_statement; 25, attribute; 26, argument_list; 27, identifier:isinstance; 28, argument_list; 29, call; 30, call; 31, identifier:encode; 32, call; 33, identifier:encoded_response_str; 34, identifier:str; 35, attribute; 36, argument_list; 37, identifier:DataTableJSONEncoder; 38, argument_list; 39, attribute; 40, argument_list; 41, identifier:encoded_response_str; 42, identifier:encode; 43, string:"utf-8"; 44, identifier:self; 45, identifier:_ToJSonObj; 46, identifier:columns_order; 47, identifier:order_by
code: def ToJSon(self, columns_order=None, order_by=()):
      """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.
      """
  
      encoded_response_str = DataTableJSONEncoder().encode(self._ToJSonObj(columns_order, order_by))
      if not isinstance(encoded_response_str, str):
        return encoded_response_str.encode("utf-8")
      return encoded_response_str