a function to add the tabulate method to a jsonModel object
        
    :param json_model: jsonModel object
    :return: jsonModel object
545026
def tabulate(json_model):
    
    '''
        
    '''

    import types
    from jsonmodel._extensions import tabulate as _tabulate
    try:
        from tabulate import tabulate
    except:
        import sys
        print('jsonmodel.extensions.tabulate requires the tabulate module. try: pip install tabulate')
        sys.exit(1)

    setattr(json_model, 'tabulate', _tabulate.__get__(json_model, types.MethodType))

    return json_model
481075
def to_json(self, propval, extraneous=False, to_json_func=None):
        
        if self.json_out:
            return self.json_out(propval)
        else:
            if not to_json_func:
                from normalize.record.json import to_json
                to_json_func = to_json
            return to_json_func(propval, extraneous)
920188
private static void insertJsonColumn(CqlSession session) {

    JsonObject alice = Json.createObjectBuilder().add("name", "alice").add("age", 30).build();

    JsonObject bob = Json.createObjectBuilder().add("name", "bob").add("age", 35).build();

    // Build and execute a simple statement
    Statement stmt =
        insertInto("examples", "json_jsr353_column")
            .value("id", literal(1))
            // the JSON object will be converted into a String and persisted into the VARCHAR column
            // "json"
            .value("json", literal(alice, session.getContext().getCodecRegistry()))
            .build();
    session.execute(stmt);

    // The JSON object can be a bound value if the statement is prepared
    // (subsequent calls to the prepare() method will return cached statement)
    PreparedStatement pst =
        session.prepare(
            insertInto("examples", "json_jsr353_column")
                .value("id", bindMarker("id"))
                .value("json", bindMarker("json"))
                .build());
    session.execute(
        pst.bind()
            .setInt("id", 2)
            // note that the codec requires that the type passed to the set() method
            // be always JsonStructure, and not a subclass of it, such as JsonObject
            .set("json", bob, JsonStructure.class));
  }
926905
def _json_column(**kwargs):
    """"""
    return db.Column(
        JSONType().with_variant(
            postgresql.JSON(none_as_null=True),
            'postgresql',
        ),
        nullable=True,
        **kwargs
    )
980680
def _format_notes(self, record):
        
        notes = []
        for note in record["notes"]:
            if note.get("type"):
                n = {}
                n["type"] = note["type"]
                try:
                    if note["jsonmodel_type"] == "note_singlepart":
                        n["content"] = note["content"][0]
                    else:
                        n["content"] = note["subnotes"][0]["content"]
                except (IndexError, KeyError):
                    n["content"] = ""

                notes.append(n)

        return notes
422635
def _convert_json_response_to_tables(response):
    ''' 
    '''
    if response is None:
        return response

    tables = _list()

    continuation = _get_continuation_from_response_headers(response)
    tables.next_marker = continuation.get('NextTableName')

    root = loads(response.body.decode('utf-8'))

    if 'TableName' in root:
        table = Table()
        table.name = root['TableName']
        tables.append(table)
    else:
        for element in root['value']:
            table = Table()
            table.name = element['TableName']
            tables.append(table)

    return tables
1057636
def update_from_json(self, json_device):
        """"""
        self.identifier = json_device['Id']
        self.license_plate = json_device['EquipmentHeader']['SerialNumber']
        self.make = json_device['EquipmentHeader']['Make']
        self.model = json_device['EquipmentHeader']['Model']
        self.equipment_id = json_device['EquipmentHeader']['EquipmentID']
        self.active = json_device['EngineRunning']
        self.odo = json_device['Odometer']
        self.latitude = json_device['Location']['Latitude']
        self.longitude = json_device['Location']['Longitude']
        self.altitude = json_device['Location']['Altitude']
        self.speed = json_device['Speed']
        self.last_seen = json_device['Location']['DateTime']
585882
def update_models(self, model, name, info):
        

        if info.method_name in ["add_input_data_port", "remove_input_data_port", "input_data_ports"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("input_data_port")
        elif info.method_name in ["add_output_data_port", "remove_output_data_port", "output_data_ports"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("output_data_port")
        elif info.method_name in ["add_income", "remove_income", "income"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("income")
        elif info.method_name in ["add_outcome", "remove_outcome", "outcomes"]:
            (model_list, data_list, model_name, model_class, model_key) = self.get_model_info("outcome")
        else:
            return

        if "add" in info.method_name:
            self.add_missing_model(model_list, data_list, model_name, model_class, model_key)
        elif "remove" in info.method_name:
            destroy = info.kwargs.get('destroy', True)
            self.remove_specific_model(model_list, info.result, model_key, destroy)
        elif info.method_name in ["input_data_ports", "output_data_ports", "income", "outcomes"]:
            self.re_initiate_model_list(model_list, data_list, model_name, model_class, model_key)
710214
def convert(self, json_input):
        
        html_output = self._table_opening_tag
        if self._build_top_to_bottom:
            html_output += self._markup_header_row(json_input.keys())
            html_output += "<tr>"
            for value in json_input.values():
                if isinstance(value, list):
                    # check if all keys in the list are identical
                    # and group all values under a common column
                    # heading if so, if not default to normal markup
                    html_output += self._maybe_club(value)
                else:
                    html_output += self._markup_table_cell(value)
            html_output += "</tr>"
        else:
            for key, value in iter(json_input.items()):
                html_output += "<tr><th>{:s}</th>".format(self._markup(key))
                if isinstance(value, list):
                    html_output += self._maybe_club(value)
                else:
                    html_output += self._markup_table_cell(value)
                html_output += "</tr>"
        html_output += "</table>"
        return html_output
988684
def custom_parser(self, json_text=None):
        
        app_config = django_apps.get_app_config("django_collect_offline")
        for json_parser in app_config.custom_json_parsers:
            json_text = json_parser(json_text)
        return json_text
1033301
def tabular(client, records):
    
    from renku.models._tabulate import tabulate

    echo_via_pager(
        tabulate(
            records,
            headers=OrderedDict((
                ('added', None),
                ('authors_csv', 'authors'),
                ('dataset', None),
                ('full_path', 'path'),
            )),
        )
    )
942193
public JTable createTable(TableModel model) {
		return (getTableFactory() != null) ? getTableFactory().createTable(model) : new JTable(model);
	}
645316
def _attach_record_as_json(mfg_event, record):
  """"""
  attachment = mfg_event.attachment.add()
  attachment.name = TEST_RECORD_ATTACHMENT_NAME
  test_record_dict = htf_data.convert_to_base_types(record)
  attachment.value_binary = _convert_object_to_json(test_record_dict)
  attachment.type = test_runs_pb2.TEXT_UTF8
578252
def field_pklist_to_json(self, model, pks):
        
        app_label = model._meta.app_label
        model_name = model._meta.model_name
        return {
            'app': app_label,
            'model': model_name,
            'pks': list(pks),
        }
627109
def update(self, json_state):
        
        self._json_state.update(
            {k: json_state[k] for k in json_state if self._json_state.get(k)})
        self._update_name()
1327458
def append_from_json(self, json_string):
        
        a_dict = json.loads(json_string)
        self.append_from_dict(a_dict)
119023
def _json_body_(cls):
        
        json = []
        for series_name, data in six.iteritems(cls._datapoints):
            for point in data:
                json_point = {
                    "measurement": series_name,
                    "fields": {},
                    "tags": {},
                    "time": getattr(point, "time")
                }

                for field in cls._fields:
                    value = getattr(point, field)
                    if value is not None:
                        json_point['fields'][field] = value

                for tag in cls._tags:
                    json_point['tags'][tag] = getattr(point, tag)

                json.append(json_point)
        return json