nodes: 0, module; 1, function_definition; 2, function_name:_ToJSonObj; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, comment:# Creating the column JSON objects; 12, expression_statement; 13, for_statement; 14, comment:# Creating the rows jsons; 15, expression_statement; 16, for_statement; 17, expression_statement; 18, if_statement; 19, return_statement; 20, identifier:columns_order; 21, None; 22, identifier:order_by; 23, tuple; 24, comment:"""Returns an object suitable to be converted to JSON.
  
      Args:
        columns_order: Optional. A list of all column IDs in the order in which
                       you want them created in the output table. If specified,
                       all column IDs must be present.
        order_by: Optional. Specifies the name of the column(s) to sort by.
                  Passed as is to _PreparedData().
  
      Returns:
        A dictionary object for use by ToJSon or ToJSonResponse.
      """; 25, comparison_operator:columns_order is None; 26, block; 27, assignment; 28, assignment; 29, identifier:col_id; 30, identifier:columns_order; 31, block; 32, assignment; 33, pattern_list; 34, call; 35, block; 36, assignment; 37, attribute; 38, block; 39, identifier:json_obj; 40, identifier:columns_order; 41, None; 42, expression_statement; 43, identifier:col_dict; 44, call; 45, identifier:col_objs; 46, list; 47, expression_statement; 48, if_statement; 49, expression_statement; 50, identifier:row_objs; 51, list; 52, identifier:row; 53, identifier:cp; 54, attribute; 55, argument_list; 56, expression_statement; 57, for_statement; 58, expression_statement; 59, if_statement; 60, expression_statement; 61, identifier:json_obj; 62, dictionary; 63, identifier:self; 64, identifier:custom_properties; 65, expression_statement; 66, assignment; 67, identifier:dict; 68, argument_list; 69, assignment; 70, subscript; 71, block; 72, call; 73, identifier:self; 74, identifier:_PreparedData; 75, identifier:order_by; 76, assignment; 77, identifier:col; 78, identifier:columns_order; 79, block; 80, assignment; 81, identifier:cp; 82, block; 83, call; 84, pair; 85, pair; 86, assignment; 87, identifier:columns_order; 88, list_comprehension; 89, list_comprehension; 90, identifier:col_obj; 91, dictionary; 92, subscript; 93, string:"custom_properties"; 94, expression_statement; 95, attribute; 96, argument_list; 97, identifier:cell_objs; 98, list; 99, expression_statement; 100, if_statement; 101, expression_statement; 102, identifier:row_obj; 103, dictionary; 104, expression_statement; 105, attribute; 106, argument_list; 107, string:"cols"; 108, identifier:col_objs; 109, string:"rows"; 110, identifier:row_objs; 111, subscript; 112, attribute; 113, subscript; 114, for_in_clause; 115, tuple; 116, for_in_clause; 117, pair; 118, pair; 119, pair; 120, identifier:col_dict; 121, identifier:col_id; 122, assignment; 123, identifier:col_objs; 124, identifier:append; 125, identifier:col_obj; 126, assignment; 127, comparison_operator:value is None; 128, block; 129, elif_clause; 130, else_clause; 131, call; 132, pair; 133, assignment; 134, identifier:row_objs; 135, identifier:append; 136, identifier:row_obj; 137, identifier:json_obj; 138, string:"p"; 139, identifier:self; 140, identifier:custom_properties; 141, identifier:col; 142, string:"id"; 143, identifier:col; 144, attribute; 145, subscript; 146, identifier:col; 147, identifier:col; 148, attribute; 149, string:"id"; 150, subscript; 151, string:"label"; 152, subscript; 153, string:"type"; 154, subscript; 155, subscript; 156, subscript; 157, identifier:value; 158, call; 159, identifier:value; 160, None; 161, expression_statement; 162, call; 163, block; 164, block; 165, attribute; 166, argument_list; 167, string:"c"; 168, identifier:cell_objs; 169, subscript; 170, identifier:cp; 171, identifier:self; 172, identifier:__columns; 173, identifier:col; 174, string:"id"; 175, identifier:self; 176, identifier:__columns; 177, subscript; 178, string:"id"; 179, subscript; 180, string:"label"; 181, subscript; 182, string:"type"; 183, identifier:col_obj; 184, string:"p"; 185, subscript; 186, string:"custom_properties"; 187, attribute; 188, argument_list; 189, assignment; 190, identifier:isinstance; 191, argument_list; 192, expression_statement; 193, if_statement; 194, if_statement; 195, expression_statement; 196, identifier:cell_objs; 197, identifier:append; 198, identifier:cell_obj; 199, identifier:row_obj; 200, string:"p"; 201, identifier:col_dict; 202, identifier:col_id; 203, identifier:col_dict; 204, identifier:col_id; 205, identifier:col_dict; 206, identifier:col_id; 207, identifier:col_dict; 208, identifier:col_id; 209, identifier:self; 210, identifier:CoerceValue; 211, call; 212, subscript; 213, identifier:cell_obj; 214, None; 215, identifier:value; 216, identifier:tuple; 217, assignment; 218, boolean_operator; 219, block; 220, comparison_operator:len(value) == 3; 221, block; 222, assignment; 223, attribute; 224, argument_list; 225, subscript; 226, string:"type"; 227, identifier:cell_obj; 228, dictionary; 229, comparison_operator:len(value) > 1; 230, comparison_operator:value[1] is not None; 231, expression_statement; 232, call; 233, integer:3; 234, expression_statement; 235, identifier:cell_obj; 236, dictionary; 237, identifier:row; 238, identifier:get; 239, identifier:col; 240, None; 241, identifier:col_dict; 242, identifier:col; 243, pair; 244, call; 245, integer:1; 246, subscript; 247, None; 248, assignment; 249, identifier:len; 250, argument_list; 251, assignment; 252, pair; 253, string:"v"; 254, subscript; 255, identifier:len; 256, argument_list; 257, identifier:value; 258, integer:1; 259, subscript; 260, subscript; 261, identifier:value; 262, subscript; 263, subscript; 264, string:"v"; 265, identifier:value; 266, identifier:value; 267, integer:0; 268, identifier:value; 269, identifier:cell_obj; 270, string:"f"; 271, identifier:value; 272, integer:1; 273, identifier:cell_obj; 274, string:"p"; 275, identifier:value; 276, integer:2
code: def _ToJSonObj(self, columns_order=None, order_by=()):
      """Returns an object suitable to be converted to JSON.
  
      Args:
        columns_order: Optional. A list of all column IDs in the order in which
                       you want them created in the output table. If specified,
                       all column IDs must be present.
        order_by: Optional. Specifies the name of the column(s) to sort by.
                  Passed as is to _PreparedData().
  
      Returns:
        A dictionary object for use by ToJSon or ToJSonResponse.
      """
      if columns_order is None:
        columns_order = [col["id"] for col in self.__columns]
      col_dict = dict([(col["id"], col) for col in self.__columns])
  
      # Creating the column JSON objects
      col_objs = []
      for col_id in columns_order:
        col_obj = {"id": col_dict[col_id]["id"],
                   "label": col_dict[col_id]["label"],
                   "type": col_dict[col_id]["type"]}
        if col_dict[col_id]["custom_properties"]:
          col_obj["p"] = col_dict[col_id]["custom_properties"]
        col_objs.append(col_obj)
  
      # Creating the rows jsons
      row_objs = []
      for row, cp in self._PreparedData(order_by):
        cell_objs = []
        for col in columns_order:
          value = self.CoerceValue(row.get(col, None), col_dict[col]["type"])
          if value is None:
            cell_obj = None
          elif isinstance(value, tuple):
            cell_obj = {"v": value[0]}
            if len(value) > 1 and value[1] is not None:
              cell_obj["f"] = value[1]
            if len(value) == 3:
              cell_obj["p"] = value[2]
          else:
            cell_obj = {"v": value}
          cell_objs.append(cell_obj)
        row_obj = {"c": cell_objs}
        if cp:
          row_obj["p"] = cp
        row_objs.append(row_obj)
  
      json_obj = {"cols": col_objs, "rows": row_objs}
      if self.custom_properties:
        json_obj["p"] = self.custom_properties
  
      return json_obj