Java Code Examples for org.json.JSONObject.quote()

The following are Jave code examples for showing how to use quote() of the org.json.JSONObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: nat-network-transfer   File: FileUploadResult.java   View Source Code Vote up 7 votes
public JSONObject toJSONObject() throws JSONException {
    return new JSONObject(
            "{bytesSent:" + bytesSent +
            ",responseCode:" + responseCode +
            ",response:" + JSONObject.quote(response) +
            ",objectId:" + JSONObject.quote(objectId) + "}");
}
 
Example 2
Project: aos-Video   File: VideoMetadata.java   View Source Code Vote up 6 votes
public ContentValues toContentValues(){
    ContentValues cv = new ContentValues();
    cv.put(MediaStore.Video.VideoColumns.WIDTH,String.valueOf(mVideoWidth));
    cv.put(MediaStore.Video.VideoColumns.HEIGHT ,String.valueOf(mVideoHeight));
    if(mVideoTrack!=null) {
        cv.put(VideoStore.Video.VideoColumns.ARCHOS_VIDEO_BITRATE, mVideoTrack.bitRate);
        cv.put(VideoStore.Video.VideoColumns.ARCHOS_FRAMES_PER_THOUSAND_SECONDS, String.valueOf(mVideoTrack.fpsRate * 100));
        cv.put(VideoStore.Video.VideoColumns.ARCHOS_CALCULATED_VIDEO_FORMAT, mVideoTrack.format);
    }
    String json = "{ audiotracks:[ ";

    for (int n=0; n<getAudioTrackNb(); n++) {

            json += "{format : "+ JSONObject.quote(getAudioTrack(n).format);
            json += ",";
            json += "channels : "+ JSONObject.quote(getAudioTrack(n).channels)+"}";

            cv.put(VideoStore.Video.VideoColumns.ARCHOS_CALCULATED_BEST_AUDIOTRACK_FORMAT,getAudioTrack(n).format);

           if(n<getAudioTrackNb()-1)
               json += ",";

    }
    json+="]}";
    cv.put(VideoStore.Video.VideoColumns.ARCHOS_CALCULATED_BEST_AUDIOTRACK_FORMAT,json);

    return cv;

}
 
Example 3
Project: siiMobilityAppKit   File: FileUploadResult.java   View Source Code Vote up 5 votes
public JSONObject toJSONObject() throws JSONException {
    return new JSONObject(
            "{bytesSent:" + bytesSent +
            ",responseCode:" + responseCode +
            ",response:" + JSONObject.quote(response) +
            ",objectId:" + JSONObject.quote(objectId) + "}");
}
 
Example 4
Project: siiMobilityAppKit   File: FileUploadResult.java   View Source Code Vote up 5 votes
public JSONObject toJSONObject() throws JSONException {
    return new JSONObject(
            "{bytesSent:" + bytesSent +
            ",responseCode:" + responseCode +
            ",response:" + JSONObject.quote(response) +
            ",objectId:" + JSONObject.quote(objectId) + "}");
}
 
Example 5
Project: COB   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 6
Project: cordova-vuetify   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 7
Project: keemob   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 8
Project: keemob   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 9
Project: Blockly   File: BlockDefinition.java   View Source Code Vote up 4 votes
/**
 * Initializes the definition from a JSON object.
 * @param json The JSON object with the definition.
 * @throws BlockLoadingException If JSON does not include expected attributes.
 */
public BlockDefinition(JSONObject json) throws BlockLoadingException {
    mJson = json;

    // Validate or create type id.
    String tmpName = mJson.optString("type");
    String logPrefix = "";
    if (tmpName == null) {
        // Generate definition name that will be consistent across runs
        int jsonHash = json.toString().hashCode();
        tmpName = "auto-" + Integer.toHexString(jsonHash);
    } else if (isValidType(tmpName)) {
        logPrefix = "Type \"" + tmpName + "\": ";
    } else {
        String valueQuotedAndEscaped = JSONObject.quote(tmpName);
        throw new BlockLoadingException("Invalid block type name: " + valueQuotedAndEscaped);
    }
    mTypeName = tmpName;

    try {
        // A block can have either an output connection or previous connection, but it can always
        // have a next connection.
        mHasOutput = mJson.has("output");
        mHasPrevious = mJson.has("previousStatement");
        mHasNext = mJson.has("nextStatement");
        if (mHasOutput && mHasPrevious) {
            throw new BlockLoadingException(
                    logPrefix + "Block cannot have both \"output\" and \"previousStatement\".");
        }
        // Each connection may have a list of allow connection checks / types.
        mOutputChecks = mHasOutput ? Input.getChecksFromJson(mJson, "output") : null;
        mPreviousChecks = mHasPrevious ? Input.getChecksFromJson(mJson, "previousStatement") : null;
        mNextChecks = mHasNext ? Input.getChecksFromJson(mJson, "nextStatement") : null;

        mColor = parseColour(logPrefix, mJson);
        mInputsInlineDefault = parseInputsInline(logPrefix, mJson);

        mMutatorName = json.has("mutator") ? json.getString("mutator") : null;
        mExtensionNames = parseExtensions(json);
    } catch (JSONException e) {
        throw new BlockLoadingException(
                "Cannot load BlockDefinition \"" + mTypeName + "\" from JSON.", e);
    }
}
 
Example 10
Project: alerta-fraude   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 11
Project: localcloud_fe   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 12
Project: localcloud_fe   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 13
Project: siiMobilityAppKit   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 14
Project: monarch   File: GfJsonObject.java   View Source Code Vote up 4 votes
public static String quote(String string) {
  return JSONObject.quote(string);
}
 
Example 15
Project: LoRaWAN-Smart-Parking   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 16
Project: LoRaWAN-Smart-Parking   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 17
Project: DinningShare   File: PluginResult.java   View Source Code Vote up 4 votes
public String getMessage() {
    if (encodedMessage == null) {
        encodedMessage = JSONObject.quote(strMessage);
    }
    return encodedMessage;
}
 
Example 18
Project: appinventor-extensions   File: JsonUtil.java   View Source Code Vote up 4 votes
public static String getJsonRepresentation(Object value) throws JSONException {
  if (value == null || value.equals(null)) {
    return "null";
  }
  if (value instanceof FString) {
    return JSONObject.quote(value.toString());
  }
  if (value instanceof YailList) {
    return ((YailList) value).toJSONString();
  }
  // The Json tokener used in getObjectFromJson cannot handle
  // fractions.  So we Json encode fractions by first converting
  // them to doubles. This is an example of value with Kawa type any
  // being exposed to the rest of App Inventor by the value being
  // passed to a component method, in this case TinyDB or TinyWebDB
  // StoreValue.  See the "warning" comment in runtime.scm at
  // call-component-method.
  if (value instanceof IntFraction) {
    return JSONObject.numberToString((Number) ((IntFraction)value).doubleValue());
  }
  if (value instanceof Number) {
    return JSONObject.numberToString((Number) value);
  }
  if (value instanceof Boolean) {
    return value.toString();
  }
  if (value instanceof List) {
    value = ((List)value).toArray();
  }
  if (value.getClass().isArray()) {
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    String separator = "";
    for (Object o: (Object[]) value) {
      sb.append(separator).append(getJsonRepresentation(o));
      separator = ",";
    }
    sb.append("]");
    return sb.toString();
  }
  return JSONObject.quote(value.toString());
}