org.json.simple.JSONObject.escape()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(405)

本文整理了Java中org.json.simple.JSONObject.escape()方法的一些代码示例,展示了JSONObject.escape()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.escape()方法的具体详情如下:
包路径:org.json.simple.JSONObject
类名称:JSONObject
方法名:escape

JSONObject.escape介绍

[英]Escape quotes, , /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F). It's the same as JSONValue.escape() only for compatibility here.
[中]转义引号、\、/、\r\n\b\f\t和其他控制字符(U+0000到U+001F)。它与JSONValue相同。escape()仅用于此处的兼容性。

代码示例

代码示例来源:origin: shopizer-ecommerce/shopizer

protected String getJsonInfo() {
  
  StringBuilder returnString = new StringBuilder();
  returnString.append("{");
  returnString.append("\"response\"").append(":");
  returnString.append("{");
  returnString.append("\"status\"").append(":").append(this.getStatus());
  if(this.getStatusMessage()!=null && this.getStatus()!=0) {
    returnString.append(",").append("\"statusMessage\"").append(":\"").append(JSONObject.escape(this.getStatusMessage())).append("\"");
  }
  return returnString.toString();
  
}

代码示例来源:origin: com.googlecode.json-simple/json-simple

Map.Entry entry=(Map.Entry)iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
out.write('\"');
out.write(':');

代码示例来源:origin: geotools/geotools

public static StringBuilder string(String string, StringBuilder sb) {
  sb.append("\"").append(JSONObject.escape(string)).append("\"");
  return sb;
}

代码示例来源:origin: i2p/i2p.i2p

Map.Entry entry=(Map.Entry)iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
out.write('\"');
out.write(':');

代码示例来源:origin: org.geotools/gt-geojson

public static StringBuilder string(String string, StringBuilder sb) {
  sb.append("\"").append(JSONObject.escape(string)).append("\"");
  return sb;
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static String toString(String key,Object value){
  StringBuilder sb=new StringBuilder();
  sb.append("\"");
  sb.append(escape(key));
  sb.append("\":");
  if(value==null){
    sb.append("null");
    return sb.toString();
  }
  if(value instanceof String){
    sb.append("\"");
    sb.append(escape((String)value));
    sb.append("\"");
  }
  else
    sb.append(value);
  return sb.toString();
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static void toString(StringBuilder sb, String key,Object value){
  sb.append("\"");
  escape(sb,key);
  sb.append("\":");
  if(value==null){
    sb.append("null");
    return;
  }
  if(value instanceof String){
    sb.append("\"");
    escape(sb,(String)value);
    sb.append("\"");
  }else if ( value instanceof JSONObject ){
    ((JSONObject)value).toString( sb );
  }else if ( value instanceof JSONArray ){
    ((JSONArray)value).toString( sb );
  }else{
    sb.append(String.valueOf( value ));
  }
}

代码示例来源:origin: fangyidong/json-simple

Map.Entry entry=(Map.Entry)iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
out.write('\"');
out.write(':');

代码示例来源:origin: childe/hangout

Map.Entry entry=(Map.Entry)iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
out.write('\"');
out.write(':');

代码示例来源:origin: com.atlassian.plugins/atlassian-connect-core

@Override
public <T extends Map<String, String>> InitializedBuilder productContext(T productContext) {
  String json = new JSONObject(productContext).toString();
  String transformed;
  if (isJSON) {
    transformed = JSONObject.escape(json);
  } else {
    StringWriter writer = new StringWriter();
    try {
      JavascriptEncoder.escape(writer, json);
      transformed = writer.toString();
    } catch (IOException e) {
      // there's no I/O, so there shouldn't be an IOException
      throw new IllegalStateException(e);
    }
  }
  additionalContext.put("productContextHtml", transformed);
  return this;
}

代码示例来源:origin: pstehlik/gelf4j

Map.Entry entry=(Map.Entry)iter.next();
out.write('\"');
out.write(escape(String.valueOf(entry.getKey())));
out.write('\"');
out.write(':');

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void
resultsComplete(
  Engine         engine )
{
  Map<String, Object> params = new HashMap<>();
  params.put( "id", new Long( id ));
  if ( sid != null )params.put( "sid", sid );
  params.put( "content", JSONObject.escape( content ));
  JSONArray    l_matches = new JSONArray();
  params.put( "matches", l_matches );
  for (int i=0;i<matches.size();i++){
    String[]    match = (String[])matches.get(i);
    JSONArray    l_match = new JSONArray();
    l_matches.add( l_match );
    Collections.addAll(l_match, match);
  }
  sendBrowserMessage( "metasearch", "testTemplateCompleted", params );
}

代码示例来源:origin: BiglySoftware/BiglyBT

public void toString( StringBuilder sb ){
    sb.append( "[" );

    Iterator<Object> iter=iterator();

    boolean	first = true;
    while(iter.hasNext()){
      if ( first ){
        first = false;
      }else{
        sb.append( "," );
      }
      Object value=iter.next();
      if(value instanceof String){
        sb.append( "\"" );
        JSONObject.escape(sb, (String)value);
        sb.append( "\"");
      }else if ( value instanceof JSONObject ){
        ((JSONObject)value).toString( sb );
      }else if ( value instanceof JSONArray ){
        ((JSONArray)value).toString( sb );
      }else{
        sb.append(String.valueOf(value));
      }
    }

    sb.append( "]" );
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

public String toString(){
  ItemList list=new ItemList();
  Iterator<Object> iter=iterator();
  while(iter.hasNext()){
    Object value=iter.next();
    if(value instanceof String){
      list.add("\""+JSONObject.escape((String)value)+"\"");
    }
    else
      list.add(String.valueOf(value));
  }
  return "["+list.toString()+"]";
}

代码示例来源:origin: org.alfresco/alfresco-repository

dateObj.put("value", JSONObject.escape(value.toString()));
dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date)value)));
return dateObj;

代码示例来源:origin: Alfresco/alfresco-repository

dateObj.put("value", JSONObject.escape(value.toString()));
dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date)value)));
return dateObj;

代码示例来源:origin: SpoonLabs/astor

for (HunkStatEnum hs : HunkStatEnum.values()) {
    if (statshunk.containsKey(hs))
      hunkjson.put(hs.name(), JSONObject.escape(statshunk.get(hs).toString()));
try {
  if (stats.containsKey(statKey))
    patchjson.put(statKey.name(), JSONObject.escape(stats.get(statKey).toString()));
} catch (Exception e) {
  log.error(e);

代码示例来源:origin: BiglySoftware/BiglyBT

int type = engine.getType();
params.put("type", type < Engine.ENGINE_TYPE_STRS.length ? Engine.ENGINE_TYPE_STRS[type] : type);
params.put("value", JSONObject.escape( engine.exportToJSONString()));
params.put("shareable", Boolean.valueOf(engine.isShareable()));

相关文章