在Android中通过JSONObject时,正向斜杠转换为\/时

在Android中通过JSONObject时,正向斜杠转换为\/时,android,jsonobject,Android,Jsonobject,我有一个字符串正在放入JSONObject中。它在通过之前看起来是这样的: Before: /storage/sdcard/Download/signature-1383757302516.jpg After: \/storage\/sdcard\/Download\/signature-1383757302516.jpg 下面是我的代码的样子: // make JSON object to hold the information, which is sent to the

我有一个字符串正在放入JSONObject中。它在通过之前看起来是这样的:

  Before: /storage/sdcard/Download/signature-1383757302516.jpg

  After: \/storage\/sdcard\/Download\/signature-1383757302516.jpg
下面是我的代码的样子:

   // make JSON object to hold the information, which is sent to the server
  JSONObject jsonObjSend = new JSONObject();
  jsonObjSend.put("signature", signatureFile.getAbsolutePath())
jsonObjSend().toString()的输出为:

JSONOBject是否对信息进行编码?如何防止它修改正斜杠

*编辑: 我用正则表达式解决了这个问题,去掉了转义字符

  jsonObjSend.toString().replaceAll("\\\\/", "/")
toString()
方法在复杂对象上调用时通常返回带有转义字符的值。您的价值存储得很好。试着打电话

jsonObjSend.get("signature");

输出应该类似于
{“signature”,“\/storage\/sdcard\/Download\/signature-1383757302516.jpg”
,在这种情况下,额外的斜杠(\)将转义“/”。我使用的是log.I(“tag”,jsonObjectSend.get(“signature”).toString()但是输出仍然显示\/storage\/sdcard\/Download\/signature-1383757302516.jpg关于
jsonObjectSend.getString(“signature”)
?jsonObjectSend.getString(“signature”)产生相同的结果
jsonObjSend.get("signature");