Convert a Switch to a JSON object.

@param s the switch to convert
@return  the JSON object
183619
public JSONObject switchToJSON(Switch s) {
        JSONObject o = new JSONObject();
        o.put("id", s.id());
        o.put(CAPACITY_LABEL, s.getCapacity());
        return o;
    }
698919
public JSONObject toJSON() {
        JSONObject ret = new JSONObject();
        ret.put("url", url);
        if (env != null) {
            ret.put("env", env);
        }
        return ret;
    }
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);
    }
  }
1148191
public JsonNode getAttributesAsJson() {
        if (attributes == null) {
            return NullNode.instance;
        }
        Lock lock = lockForRead();
        try {
            return SerializationUtils.toJson(attributes);
        } finally {
            lock.unlock();
        }
    }
26190
public JSONObject toJSON() {
        JSONObject ret = new JSONObject();
        ret.put("type",type.getName());

        if (targetConfig != null) {
            ret.put("target", targetConfig.toJSON());
        }
        if (pathParts != null) {
            try {
                ret.put("path",getPath());
            } catch (UnsupportedOperationException exp) {
                // Happens when request doesnt support paths
            }
        }
        return ret;
    }
693063
public JSONObject asJSONObject()
    {
        if ( entity == null ) {
            return null;
        }
        String str = asString();
        try {
            return new JSONObject( str );
        } catch ( JSONException ex ) {
            throw new CStorageException( "Error parsing the JSON response: " + str, ex );
        }
    }
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;
    }
273250
def json_decode(s: str) -> Any:
    
    try:
        return json.JSONDecoder(object_hook=json_class_decoder_hook).decode(s)
    except json.JSONDecodeError:
        log.warning("Failed to decode JSON (returning None): {!r}", s)
        return None
1073664
protected <T> T fromJsonString(String json, Class<T> clazz) {
		return _gsonParser.fromJson(json, clazz);
	}
58857
public JSONArray switchesToJSON(Collection<Switch> c) {
        JSONArray a = new JSONArray();
        for (Switch s : c) {
            a.add(switchToJSON(s));
        }
        return a;
    }
267340
protected JsonObject argumentsToJson() {
    JsonObject result = new JsonObject();
    for (Argument a : _arguments) {
      if (a.specified())
        result.addProperty(a._name,a.originalValue());
    }
    return result;
  }
691090
@JsonValue
	public Object toJsonValue() {
		if (s != null)
			return s;
		if (n != null)
			return n;
		return null;
	}
1022659
@Override
	public String toJson(Object obj) {
		try {
			String json;
			if (obj == null) {
				json = null;
			}
			else {
				json = mapper.writeValueAsString(obj);
			}
			return json;
		}
		catch (Exception e) {
			throw new JsonException(e.getMessage(), e);
		}
	}
1309309
public String toJson(JsonElement jsonElement) {
    StringWriter writer = new StringWriter();
    toJson(jsonElement, writer);
    return writer.toString();
  }
970803
public JSONObject toJson() throws IOException, JSONException {
    JSONObject json = new JSONObject();

    for (CapabilityInstance option : options.values()) {
      Object value = option.getValue();

      if (value == null) {
        continue;
      }

      if (value instanceof OperaProfile) {
        value = ((OperaProfile) value).toJson();
      } else if (value instanceof OperaArguments && ((OperaArguments) value).size() > 0) {
        value = ((OperaArguments) value).toJson();
      } else if (value instanceof Boolean) {
        value = (Boolean) value ? 1 : 0;
      } else {
        value = String.valueOf(value);
      }

      json.put(option.getIdentifier(), value);
    }

    return json;
  }
14929
function convertToJson(callback) {
    var output = new File(file);
    output.contents = new Buffer(JSON.stringify(spritesheet, null, '\t'));
    output.path = file;
    this.push(output);
    callback();
  }
298431
private JSON getJSON() throws JSONMarshallException {
        if (json == null) {
            JSONSettings settings = new JSONSettings(Include.NON_NULL);
            json = JSONFactory.newInstance(settings);
        }
        return json;
    }