Adapter for rendering an item of
    :class: `pycountry.db.Data` to json.
434191
def item_land_adapter(obj, request):
    
    return {
        'id': obj.alpha_2,
        'alpha2': obj.alpha_2,
        'alpha3': obj.alpha_3,
        'naam': _(obj.name)
    }
624056
def to_json(self):
    
    cursor = self._get_cursor()
    cursor_object = False
    if cursor and isinstance(cursor, datastore_query.Cursor):
      cursor = cursor.to_websafe_string()
      cursor_object = True
    return {"key_range": self._key_range.to_json(),
            "query_spec": self._query_spec.to_json(),
            "cursor": cursor,
            "cursor_object": cursor_object}
411465
def to_json(*a)
      { :item => if item then
                   item.name
                 else
                   nil
                 end,
        :tag  => if tag then
                   tag.name
                 else
                   nil
                 end,
        :src  => path_from_catalog_root }.to_json(*a)
    end
230191
def save_to_json(self):
        """"""
        requestvalues = {
            'Dataset': self.dataset,
            'Header' : self._get_item_array(self.header),
            'Filter' : self._get_item_array(self.filter),
            'Stub' : self._get_item_array(self.stub),
            'Frequencies': self.frequencies
        }
        return json.dumps(requestvalues)
1315836
def to_json(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True,
              pretty=False):
    
    return to_json(
      self.to_dict(
        include_keys=include_keys,
        exclude_keys=exclude_keys,
        use_default_excludes=use_default_excludes),
      pretty=pretty)
935520
def _converter(data):
    
    handler = REGISTRY.get(data.__class__)
    if handler:
        full_name = '{}.{}'.format(
            data.__class__.__module__,
            data.__class__.__name__)
        return {
            '__class__': full_name,
            '__value__': handler(data),
        }
    raise TypeError(repr(data) + " is not JSON serializable")
270647
def _objectify(self, json_data=None, data={}):
        ''''''
        if json_data:
            # Parse the data
            try:
                data = json.loads(json_data)
            except ValueError:
                # If parsing failed, then raise the string which likely contains an error message instead of data
                raise RedmineError(json_data)
        # Check to see if there is a data wrapper
        # Some replies will have {'issue':{<data>}} instead of just {<data>}
        try:
            data = data[self._item_type]
        except KeyError:
            pass

        # Either returns a new item or updates the item in the cache and returns that
        return self._redmine.check_cache(self._item_type, data, self._object)
988518
def render_to_json_response(self, context, **response_kwargs):
        
        return HttpResponse(
            self.convert_context_to_json(context),
            content_type='application/json',
            **response_kwargs
        )
1222618
def jsonise(dic):
        """"""
        d = {}
        for k, v in dic.items():
            if type(v) in abstractRequetesSQL.TYPES_PERMIS:
                d[k] = v
            else:
                try:
                    d[k] = json.dumps(v, ensure_ascii=False, cls=formats.JsonEncoder)
                except ValueError as e:
                    logging.exception("Erreur d'encodage JSON !")
                    raise e
        return d
1095421
def note_adapter(obj, request):
    '''
    
    '''
    return {
        'note': obj.note,
        'type': obj.type,
        'language': obj.language,
        'markup': obj.markup
    }
228901
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        renderer_context = renderer_context or {}
        callback = self.get_callback(renderer_context)
        json = super(JSONPRenderer, self).render(data, accepted_media_type,
                                                 renderer_context)
        return callback.encode(self.charset) + b'(' + json + b');'
637970
def item_afdeling_adapter(obj, request):
    
    return {
        'id': obj.id,
        'naam': obj.naam,
        'gemeente': {
            'id': obj.gemeente.id,
            'naam': obj.gemeente.naam
        },
        'centroid': obj.centroid,
        'bounding_box': obj.bounding_box
    }
494240
def to_json(*a)
      # Hack to override RightScale namespace with Nanite for downward compatibility
      class_name = self.class.name
      if class_name =~ /^RightScale::(.*)/
        class_name = "Nanite::" + Regexp.last_match(1)
      end

      js = {
        'json_class' => class_name,
        'data'       => instance_variables.inject({}) do |m, ivar|
                          name = ivar.to_s.sub(/@/, '')
                          m[name] = instance_variable_get(ivar) unless NOT_SERIALIZED.include?(name)
                          m
                        end
      }.to_json(*a)
      @size = js.size
      js = js.chop + ",\"size\":#{@size}}"
    end
1223100
def to_json(self):
        

        result = {
            'name': self.name,
            'id': self._real_id(),
            'type': self.type,
            'localized': self.localized,
            'omitted': self.omitted,
            'required': self.required,
            'disabled': self.disabled,
            'validations': [v.to_json() for v in self.validations]
        }

        if self.type == 'Array':
            result['items'] = self.items

        if self.type == 'Link':
            result['linkType'] = self.link_type

        return result
786730
def to_json(df, state_index, color_index, fills):
        """"""
        records = {}
        for i, row in df.iterrows():

            records[row[state_index]] = {
                "fillKey": row[color_index]
            }

        return {
            "data": records,
            "fills": fills
        }
1223552
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        if 'SWAGGER_JSON_PATH' in os.environ:
            with io.open(os.environ['SWAGGER_JSON_PATH'], 'rb') as f:
                return f.read()
        else:
            return super(ConditionalOpenAPIRenderer, self).render(data, accepted_media_type, renderer_context)
876207
def as_json(data, **kwargs):
    

    if 'sort_keys' not in kwargs:
        kwargs['sort_keys'] = False
    if 'ensure_ascii' not in kwargs:
        kwargs['ensure_ascii'] = False

    data = json.dumps(data, **kwargs)

    return data