Takes a JSON object and fills its internal data-structure.

@param json the JSON Object.
496077
public void fromJson(JSONObject json) {
        super.fromJson(json);
        if (json.containsKey(CHANGE)) {
            change = new Change(json.getJSONObject(CHANGE));
        }
        if (json.containsKey(PATCH_SET)) {
            patchSet = new PatchSet(json.getJSONObject(PATCH_SET));
        } else if (json.containsKey(PATCHSET)) {
            patchSet = new PatchSet(json.getJSONObject(PATCHSET));
        }
    }
1352457
public static DataStore fromJson(final JSONObject json) throws ParseException {
        DataStore ret;

        JSONArray jsonCols = json.getJSONArray("fields");
        if (!"time".equals(jsonCols.get(0))) {
            throw new JSONException("time must be the first item in 'fields'");
        }

        Set<String> cols = new HashSet<String>();
        for (int i = 1; i < jsonCols.length(); i++) {
            cols.add(jsonCols.getString(i));
        }
        ret = new DataStore(cols);

        JSONArray jsonData = json.getJSONArray("data");
        for (int i = 0; i < jsonData.length(); i++) {
            JSONArray row = jsonData.getJSONArray(i);
            Long ts = row.getLong(0);
            Map<String, Object> vals = new HashMap<String, Object>();
            for (int j = 1; j < row.length(); j++) {
                vals.put(jsonCols.getString(j), row.get(j));
            }
            ret.rows.put(ts, vals);
        }

        return ret;
    }
496961
protected String readJsonFrom(final InputStream json) throws IOException {
        return isJsonFormat()
            ? JsonValue.readHjson(IOUtils.toString(json, StandardCharsets.UTF_8)).toString()
            : String.join("\n", IOUtils.readLines(json, StandardCharsets.UTF_8));
    }
399850
@Override
    public void loadFromJSONObject( JSONObject jobj, Database db ) throws JSONException {
        super.loadFromJSONObject(jobj, db);
        m_updatesIndexes = jobj.getBoolean( Members.UPDATES_INDEXES .name() );
    }
449006
public static Object fromJson(String json) {
    try {
      JSONObject jsonObject = new JSONObject(json);
      if (jsonObject.has("JSON")) {
        return convert(jsonObject.get("JSON"));
      } else {
        return convert(jsonObject);
      }
    } catch (Exception e) {
      throw new RuntimeException("json=" + json, e);
    }
  }
352009
def _populate(self, json):
        
        if not json:
            return

        # hide the raw JSON away in case someone needs it
        self._set('_raw_json', json)

        for key in json:
            if key in (k for k in type(self).properties.keys()
                    if not type(self).properties[k].identifier):
                if type(self).properties[key].relationship \
                    and not json[key] is None:
                    if isinstance(json[key], list):
                        objs = []
                        for d in json[key]:
                            if not 'id' in d:
                                continue
                            new_class = type(self).properties[key].relationship
                            obj = new_class.make_instance(d['id'],
                                    getattr(self,'_client'))
                            if obj:
                                obj._populate(d)
                            objs.append(obj)
                        self._set(key, objs)
                    else:
                        if isinstance(json[key], dict):
                            related_id = json[key]['id']
                        else:
                            related_id = json[key]
                        new_class = type(self).properties[key].relationship
                        obj = new_class.make_instance(related_id, getattr(self,'_client'))
                        if obj and isinstance(json[key], dict):
                            obj._populate(json[key])
                        self._set(key, obj)
                elif  type(self).properties[key].slug_relationship \
                        and not json[key] is None:
                    # create an object of the expected type with the given slug
                    self._set(key, type(self).properties[key].slug_relationship(self._client, json[key]))
                elif type(json[key]) is dict:
                    self._set(key, MappedObject(**json[key]))
                elif type(json[key]) is list:
                    # we're going to use MappedObject's behavior with lists to
                    # expand these, then grab the resulting value to set
                    mapping = MappedObject(_list=json[key])
                    self._set(key, mapping._list) # pylint: disable=no-member
                elif type(self).properties[key].is_datetime:
                    try:
                        t = time.strptime(json[key], DATE_FORMAT)
                        self._set(key, datetime.fromtimestamp(time.mktime(t)))
                    except:
                        #TODO - handle this better (or log it?)
                        self._set(key, json[key])
                else:
                    self._set(key, json[key])

        self._set('_populated', True)
        self._set('_last_updated', datetime.now())
989624
public void finishJson(final Object obj) {
        this.contentType = this.jsonContentType;
        if (this.recycleListener != null) this.output = obj;
        finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), obj));
    }
227042
public void put(String key, Object object, boolean serialize){
        if(serialize)
            put(key,gson.toJson(object));
        else
            put(key,object);
    }
153023
private static Object parseAsObject(String json) {
		if ( StringHelper.isNullOrEmptyString( json ) ) {
			return null;
		}
		Document object = Document.parse( "{ 'json': " + json + "}" );
		return object.get( "json" );
	}
592267
public T fromJson(String json) throws Exception {
    Unmarshaller u = this.getUnmarshaller();
    u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json");
    T result = this.fromString(u, json);
    return result;
  }
38516
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof Root)){
    return new Root(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(Root.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
569791
private void startJSON()
    throws SAXException
    {
        if (logger.isLoggable(Level.FINER)) logger.entering(className, "startJSON()");

        this.head    = new JSONObject("",null);
        this.current = head;

        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "startJSON()");
    }
694318
public static NeuralNetConfiguration fromJson(String json) {
        ObjectMapper mapper = mapper();
        try {
            NeuralNetConfiguration ret = mapper.readValue(json, NeuralNetConfiguration.class);
            return ret;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
687779
public void index(String indexName, String indexType, String... json) {
        index(
                Arrays.stream(json)
                        .map(item -> new IndexRequest.IndexRequestBuilder(indexName, indexType, item).build())
                        .collect(toList())
        );
    }
495063
public static boolean isValid(final String json) {
        if (Strings.isEmpty(json)) {
            return false;
        }

        try {
            return parse(json) != null;
        } catch (ParseException e) {
            return false;
        }
    }
487368
private void loadJsonResource(JSONObject json, Properties properties, Object name)
                                throws JSONException {
    Iterator<?> keys = json.keys();
    while (keys.hasNext()) {
      Object obj = keys.next();
      if (!(obj instanceof String)) {
        LOG.warn("Object not instance of string : " + obj + " skipping");
        continue;
      }
      String key = (String) obj;
      // can't have . in thrift fields so we represent . with _
      String keyUnderscoresToDots = key.replace("_", ".");  
      // actual _ are represented as __ in thrift schema
      keyUnderscoresToDots = keyUnderscoresToDots.replace("..", "_");
      if (!json.isNull(key)) {
        Object value = json.get(key);
        String stringVal = "";
        if (value instanceof String) {
          stringVal = (String)value;
        } else if (value instanceof Integer) {
            stringVal = new Integer((Integer)value).toString();
        } else if (value instanceof Long) {
            stringVal = new Long((Long)value).toString();
        } else if (value instanceof Double) {
            stringVal = new Double((Double)value).toString();
        } else if (value instanceof Boolean) {
            stringVal = new Boolean((Boolean)value).toString();
        } else if (value instanceof JSONObject) {
            loadJsonResource((JSONObject)value, properties, name);
            continue;
        } else {
            LOG.warn("unsupported value in json object: " + value);
        }
        if (!finalParameters.contains(keyUnderscoresToDots)) {
          properties.setProperty(keyUnderscoresToDots, stringVal);
          updatingResource.put(keyUnderscoresToDots, name.toString());
    	} else {
    	    LOG.warn(name+":a attempt to override final parameter: "+
                     keyUnderscoresToDots+";  Ignoring.");
    	}
      } 
    }
  }
535698
public void write(JsonWriter json, @Nullable UserDto user) {
    if (user == null) {
      json.beginObject().endObject();
    } else {
      write(json, user, Collections.emptySet(), CONCISE_FIELDS);
    }
  }