Create a JSON-serializable representation of the plane that is usable with the
        javascript frontend
167573
def to_mapping(self,**values):
        
        strike, dip, rake = self.strike_dip_rake()
        min, max = self.angular_errors()

        try:
            disabled = self.disabled
        except AttributeError:
            disabled = False

        mapping = dict(
            uid=self.hash,
            axes=self.axes.tolist(),
            hyperbolic_axes=self.hyperbolic_axes.tolist(),
            max_angular_error=max,
            min_angular_error=min,
            strike=strike,
            dip=dip,
            rake=rake,
            disabled=disabled)

        # Add in user-provided-values, overwriting if
        # necessary
        for k,v in values.items():
            mapping[k] = v
        return mapping
15720
def pretty_json(obj):
    
    if isinstance(obj, string_types):
        try:
            obj = json.loads(obj)
        except ValueError:
            raise ClientException("`obj` is not a json string")
    json_str = json.dumps(obj, sort_keys=True, indent=2)
    print(highlight(json_str, JsonLexer(), TerminalFormatter()))
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
236213
def save_json(object, handle, indent=2):
    """"""
    obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
    handle.write(obj_json)
1330497
def from_json(cls, data):
        
        required_keys = ('location', 'design_days')
        for key in required_keys:
            assert key in data, 'Required key "{}" is missing!'.format(key)

        return cls(Location.from_json(data['location']),
                   [DesignDay.from_json(des_day) for des_day in data['design_days']])
471736
def to_json(obj, seen=None):
    

    if not seen:
        seen = []

    properties = list(class_mapper(type(obj)).iterate_properties)
    relationships = [
        p.key for p in properties if type(p) is RelationshipProperty
    ]
    attrs = [
        p.key for p in properties if p.key not in relationships
    ]

    d = dict([(attr, getattr(obj, attr)) for attr in attrs])

    for attr in relationships:
        d[attr] = expand(obj, getattr(obj, attr), seen)

    return d
1186090
def fromJSON(jsonValue):
        """"""
        jd = json.loads(jsonValue)
        features = []
        if 'fields' in jd:
            fields = jd['fields']
        else:
            fields = {'fields':[]}
        if 'features' in jd:
            for feat in jd['features']:
                wkid = None
                spatialReference =None
                if 'spatialReference' in jd:
                    spatialReference = jd['spatialReference']
                    if 'wkid' in jd['spatialReference']:
                        wkid = jd['spatialReference']['wkid']
                    elif 'latestWkid' in jd['spatialReference']: # kept for compatibility
                        wkid = jd['spatialReference']['latestWkid']
                features.append(Feature(json_string=feat, wkid=wkid, spatialReference=spatialReference))
        return FeatureSet(fields,
                          features,
                          hasZ=jd['hasZ'] if 'hasZ' in jd else False,
                          hasM=jd['hasM'] if 'hasM' in jd else False,
                          geometryType=jd['geometryType'] if 'geometryType' in jd else None,
                          objectIdFieldName=jd['objectIdFieldName'] if 'objectIdFieldName' in jd else None,
                          globalIdFieldName=jd['globalIdFieldName'] if 'globalIdFieldName' in jd else None,
                          displayFieldName=jd['displayFieldName'] if 'displayFieldName' in jd else None,
                          spatialReference=jd['spatialReference'] if 'spatialReference' in jd else None)
1294701
def to_json(self):
        
        ret = {
            'address': self.address,
            'domain': self.domain,
            'block_number': self.block_height,
            'sequence': self.n,
            'txid': self.txid,
            'value_hash': get_zonefile_data_hash(self.zonefile_str),
            'zonefile': base64.b64encode(self.zonefile_str),
            'name': self.get_fqn(),
        }
        
        if self.pending is not None:
            ret['pending'] = self.pending

        if self.resolver is not None:
            ret['resolver'] = self.resolver

        return ret
437914
def as_json(context):
    """"""
    info = {
        'info': cgi.escape(pprint.pformat(context.context)),
    }
    return Response(content_type='application/json', body=json.dumps(info))
974074
function toGeoJSON(json, options = Options) {
  const collection = helpers.featureCollection([])
  json.resourceSets[0].resources.map(result => {
    // Point GeoJSON
    const point = parsePoint(result)
    const bbox = parseBBox(result)
    let confidence = confidenceScore(bbox)
    const properties = {
      confidence,
      authenticationResultCode: json.authenticationResultCode,
      brandLogoUri: json.brandLogoUri,
      copyright: json.copyright,
      entityType: result.entityType,
      matchCodes: result.matchCodes,
      name: result.name,
      statusCode: json.statusCode,
      statusDescription: json.statusDescription,
      traceId: json.traceId,
    }
    Object.keys(result.address).forEach(key => properties[key] = result.address[key])

    // Store Point to GeoJSON feature collection
    if (point) {
      point.bbox = bbox
      point.properties = properties
      collection.features.push(point)
    }
  })
  return collection
}
821564
def from_json(self, fname):
        '''
            
        '''
        with open(fname, 'rt') as fp:
            for row in json.load(fp):
                nn = ServerInfo.from_dict(row)
                self[str(nn)] = nn
339557
function toJSON(obj, pretty, def) {
    if (is_1.isString(pretty)) {
        def = pretty;
        pretty = undefined;
    }
    var tabs = 0;
    pretty = is_1.isBoolean(pretty) ? 2 : pretty;
    tabs = pretty ? pretty : tabs;
    if (!is_1.isObject(obj))
        return toDefault(null, def);
    return function_1.tryWrap(JSON.stringify, obj, null, tabs)(def);
}
358732
def fromJson(struct, attributes=None):
    ""
    if isinstance(struct, basestring):
        struct = json.loads(struct)
    indicative_attributes = {
        'x': Point,
        'wkid': SpatialReference,
        'paths': Polyline,
        'rings': Polygon,
        'points': Multipoint,
        'xmin': Envelope
    }
    # bbox string
    if isinstance(struct, basestring) and len(struct.split(',')) == 4:
        return Envelope(*map(float, struct.split(',')))
    # Look for telltale attributes in the dict
    if isinstance(struct, dict):
        for key, cls in indicative_attributes.iteritems():
            if key in struct:
                ret = cls.fromJson(dict((str(key), value)
                                   for (key, value) in struct.iteritems()))
                if attributes:
                    ret.attributes = dict((str(key.lower()), val) 
                                           for (key, val)
                                           in attributes.iteritems())
                return ret
    raise ValueError("Unconvertible to geometry")
1350921
function toJSON(value, options) {
  var propertyOrValues = {}
  var lines
  var isPropertyValuePair
  var pairs
  var values

  if (!options) {
    options = {}
  }

  if (options.log === null || options.log === undefined) {
    options.log = true
  }

  if (options.comment === null || options.comment === undefined) {
    options.comment = '%'
  }

  lines = value.split('\n')

  if (options.comment) {
    lines = lines.map(stripComments(options.comment))
  }

  lines = lines.map(trim).filter(Boolean)

  pairs = lines.map(toPropertyValuePairs(options.delimiter || ':'))

  pairs.forEach(function(line, index) {
    var currentLineIsPropertyValuePair

    currentLineIsPropertyValuePair = line.length === 2

    if (index === 0) {
      isPropertyValuePair = currentLineIsPropertyValuePair
    } else if (currentLineIsPropertyValuePair !== isPropertyValuePair) {
      throw new Error(
        'Error at `' +
          line +
          '`: ' +
          'Both property-value pairs and array values found. ' +
          'Make sure either exists.'
      )
    }

    if (own.call(propertyOrValues, line[0])) {
      if (
        !options.forgiving ||
        (options.forgiving === true &&
          currentLineIsPropertyValuePair &&
          line[1] !== propertyOrValues[line[0]])
      ) {
        throw new Error(
          'Error at `' +
            line +
            '`: ' +
            'Duplicate data found. ' +
            'Make sure, in objects, no duplicate properties exist;' +
            'in arrays, no duplicate values.'
        )
      }

      if (options.log) {
        if (
          options.forgiving === 'fix' &&
          propertyOrValues[line[0]] !== line[1]
        ) {
          console.log(
            'Overwriting `' +
              propertyOrValues[line[0]] +
              '` ' +
              'to `' +
              line[1] +
              '` for `' +
              line[0] +
              '`'
          )
        } else {
          console.log('Ignoring duplicate key for `' + line[0] + '`')
        }
      }
    }

    propertyOrValues[line[0]] = line[1]
  })

  if (isPropertyValuePair) {
    pairs.sort(sortOnFirstIndex)
    values = propertyValuePairsToObject(pairs)
  } else {
    lines.sort()
  }

  return values || lines
}
1285157
private JsonNode toJson(){
    	ObjectNode result = new ObjectNode(Topology.OBJECT_MAPPER.getNodeFactory());
        ArrayNode propertyArrayNode = new ArrayNode(Topology.OBJECT_MAPPER.getNodeFactory());
        for (PropertyColumn property : this.properties) {
            ObjectNode objectNode = property.toNotifyJson();
            objectNode.put("schemaName", property.getParentLabel().getSchema().getName());
            objectNode.put("abstractLabelLabel", property.getParentLabel().getLabel());
            propertyArrayNode.add(objectNode);
        }
        result.put("name", getName());
        result.set("properties", propertyArrayNode);
        return result;
    }
338891
def json(self, build_context) -> str:
        """"""
        if self._json is None:
            self.compute_json(build_context)
        return self._json
211194
def _create_json(self):
        
        data_json = {
            "name": self.name,
            "description": self.description,
            "autoJoin": self.autoJoin,
            "realm": self.realm,
        }
        return data_json