Code example for JsonObject

Methods: addProperty, JsonObject.addProperty

		addProperty(json, "since_seq", sinceSeq);
		addProperty(json, "create_target", createTarget);
		if(targetOauth != null) {
			JsonObject auth = new JsonObject();
			JsonObject oauth = new JsonObject();
			addProperty(oauth, "consumer_secret", consumerSecret);
			addProperty(oauth, "consumer_key", consumerKey);
			addProperty(oauth, "token_secret", tokenSecret);
			addProperty(oauth, "token", token);
			addProperty(targetOauth, "url", target);
			auth.add("oauth", oauth);
			targetOauth.add("auth", auth);
			json.add("target", targetOauth);
		} else { 
			addProperty(json, "target", target);
		return json;
	private void addProperty(JsonObject json, String name, Object value) {
		if(value != null) {
			if(value instanceof Boolean)
				json.addProperty(name, (Boolean)value);
			else if (value instanceof String)
				json.addProperty(name, (String)value);
			else if (value instanceof Integer)
				json.addProperty(name, (Integer)value);
Connect your IDE to all the code out there  Get Codota for Java