Serialize this JSONArray to a string.

@param jsonReferenceToId
the map from json reference to id
@param includeNullValuedFields
whether to include null-valued fields
@param depth
the nesting depth
@param indentWidth
the indent width
@param buf
the buf
19630
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
            final boolean includeNullValuedFields, final int depth, final int indentWidth,
            final StringBuilder buf) {
        final boolean prettyPrint = indentWidth > 0;
        final int n = items.size();
        if (n == 0) {
            buf.append("[]");
        } else {
            buf.append('[');
            if (prettyPrint) {
                buf.append('\n');
            }
            for (int i = 0; i < n; i++) {
                final Object item = items.get(i);
                if (prettyPrint) {
                    JSONUtils.indent(depth + 1, indentWidth, buf);
                }
                JSONSerializer.jsonValToJSONString(item, jsonReferenceToId, includeNullValuedFields, depth + 1,
                        indentWidth, buf);
                if (i < n - 1) {
                    buf.append(',');
                }
                if (prettyPrint) {
                    buf.append('\n');
                }
            }
            if (prettyPrint) {
                JSONUtils.indent(depth, indentWidth, buf);
            }
            buf.append(']');
        }
    }
801956
@SuppressWarnings("unchecked")
    String getFormattedTabularData(TabularData td, String indent) {
        StringBuilder sb = new StringBuilder();
        indent += INDENT;

        sb.append("{");
        Collection<CompositeData> values = (Collection<CompositeData>) td.values();
        int valuesRemaining = values.size();
        for (CompositeData cd : values) {
            sb.append(getFormattedCompositeData(cd, indent));
            if (--valuesRemaining > 0) {
                sb.append("\n").append(indent).append("}, {");
            }
        }
        sb.append("}");

        return String.valueOf(sb);
    }
38878
public static String stringify(final JsonNode json) {
        try {
            return json != null ? createObjectMapper().writeValueAsString(json) : "{}";
        } catch (JsonProcessingException jpx) {
            throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx);
        }
    }
715020
private static String generateTab(int depth) {
    StringBuilder builder = new StringBuilder();
    if (depth != 0) {
      builder.append("  ");
    }

    for (int i = 1; i < depth; i++) {
      builder.append("|  ");
    }

    return builder.append("+--").toString();
  }
806161
@Override
	public String toJSONString(int indentFactor) throws JSONException {
		StringWriter sw = new StringWriter();
		synchronized (sw.getBuffer()) {
			return this.write(sw, indentFactor, 0).toString();
		}
	}
638988
public static JSONObjectException wrapWithPath(Throwable src, Reference ref)
    {
        JSONObjectException jme;
        if (src instanceof JSONObjectException) {
            jme = (JSONObjectException) src;
        } else {
            String msg = src.getMessage();
            if (msg == null || msg.length() == 0) {
                msg = "(was "+src.getClass().getName()+")";
            }
            jme = new JSONObjectException(msg, null, src);
        }
        jme.prependPath(ref);
        return jme;
    }
919327
public JsonWriter nullValue() throws IOException {
    if (deferredName != null) {
      if (serializeNulls) {
        writeDeferredName();
      } else {
        deferredName = null;
        return this; // skip the name and the value
      }
    }
    beforeValue();
    out.write("null");
    return this;
  }
733953
protected SFSDataWrapper transformNotNullValue(Object object) {
        Object value = serializeObject(object);
        if(value instanceof Parameters)
            return transformParams((Parameters)value);
        if(value instanceof Parameters[])
            return transformParamsArray((Parameters[])value);
        return super.transformNotNullValue(value);
    }
862331
public String toJSON(final int indentWidth) {
        if (closed.get()) {
            throw new IllegalArgumentException("Cannot use a ScanResult after it has been closed");
        }
        if (!scanSpec.enableClassInfo) {
            throw new IllegalArgumentException("Please call ClassGraph#enableClassInfo() before #scan()");
        }
        final List<ClassInfo> allClassInfo = new ArrayList<>(classNameToClassInfo.values());
        CollectionUtils.sortIfNotEmpty(allClassInfo);
        final List<PackageInfo> allPackageInfo = new ArrayList<>(packageNameToPackageInfo.values());
        CollectionUtils.sortIfNotEmpty(allPackageInfo);
        final List<ModuleInfo> allModuleInfo = new ArrayList<>(moduleNameToModuleInfo.values());
        CollectionUtils.sortIfNotEmpty(allModuleInfo);
        return JSONSerializer.serializeObject(new SerializationFormat(CURRENT_SERIALIZATION_FORMAT, scanSpec,
                allClassInfo, allPackageInfo, allModuleInfo, rawClasspathEltOrderStrs), indentWidth, false);
    }
925800
def to_json_string(self, indent=None):
        ''' 

        '''
        root_ids = []
        for r in self._roots:
            root_ids.append(r.id)

        root_references = self._all_models.values()

        json = {
            'title' : self.title,
            'roots' : {
                'root_ids' : root_ids,
                'references' : references_json(root_references)
            },
            'version' : __version__
        }

        return serialize_json(json, indent=indent)
1330615
public void toStringRep(String indent, Map<String, String> nss, 
            XNAppender out, Consumer<? super XRepresentationRecord> callback) {
        
        Map<String, String> nss0 = new HashMap<>(nss);
        
        out.append(indent);
        
        if (callback != null) {
            callback.accept(new XRepresentationRecord(XRepresentationState.START_ELEMENT, this, 
                    out.length()));
        }
        out.append("<");
        
        Pair<String, String> pf = createPrefix(nss0, namespace, prefix);
        
        String prefix = pf.first;
        if (prefix != null && prefix.length() > 0) {
            out.append(prefix).append(":");
        }
        out.append(name);

        if (pf.second != null) {
            out.append(pf.second);
        }
        
        if (attributes.size() > 0) {
            for (XAttributeName an : attributes.keySet()) {
                Pair<String, String> pfa = createPrefix(nss0, an.namespace, an.prefix);
                out.append(" ");
                if (pfa.first != null && pfa.first.length() > 0) {
                    out.append(pfa.first).append(":");
                }
                out.append(an.name).append("='").append(sanitize(attributes.get(an))).append("'");
                
                if (pfa.second != null) {
                    out.append(pfa.second);
                }
                
            }
        }
        
        if (children.size() == 0) {
            if (content == null || content.isEmpty()) {
                out.append("/>");
            } else {
                out.append(">");
                if (callback != null) {
                    callback.accept(new XRepresentationRecord(XRepresentationState.START_TEXT, this, out.length()));
                }
                String s = sanitize(content);
                out.append(s);
                if (callback != null) {
                    callback.accept(new XRepresentationRecord(XRepresentationState.END_TEXT, this, out.length()));
                }
                if (s.endsWith("\n")) {
                    out.append(indent);
                }
                out.append("</");
                if (prefix != null && prefix.length() > 0) {
                    out.append(prefix).append(":");
                }
                out.append(name);
                out.append(">");
            }
        } else {
            if (content == null || content.isEmpty()) {
                out.append(String.format(">%n"));
            } else {
                out.append(">");
                if (callback != null) {
                    callback.accept(new XRepresentationRecord(XRepresentationState.START_TEXT, this, out.length()));
                }
                out.append(sanitize(content));
                if (callback != null) {
                    callback.accept(new XRepresentationRecord(XRepresentationState.END_TEXT, this, out.length()));
                }

                out.append(String.format("%n"));
            }
            for (XNElement e : children) {
                e.toStringRep(indent + "  ", nss0, out, callback);
            }
            out.append(indent).append("</");
            if (prefix != null && prefix.length() > 0) {
                out.append(prefix).append(":");
            }
            out.append(name);
            out.append(">");
        }
        if (callback != null) {
            callback.accept(new XRepresentationRecord(XRepresentationState.END_ELEMENT, this, out.length()));
        }
        out.append(String.format("%n"));
    }
6993
@Override
  public JsonElement serialize(CMAEntry src, Type type, JsonSerializationContext context) {
    JsonObject fields = new JsonObject();
    for (Map.Entry<String, LinkedHashMap<String, Object>> field : src.getFields().entrySet()) {
      LinkedHashMap<String, Object> value = field.getValue();
      if (value == null) {
        continue;
      }
      String fieldId = field.getKey();
      JsonObject jsonField = serializeField(context, field.getValue());
      if (jsonField != null) {
        fields.add(fieldId, jsonField);
      }
    }

    JsonObject result = new JsonObject();
    result.add("fields", fields);

    final CMASystem sys = src.getSystem();
    if (sys != null) {
      result.add("sys", context.serialize(sys));
    }
    return result;
  }
167263
private String getTextField(JsonNode json, String fieldName) {
        if (!json.has(fieldName)) {
            return null;
        }
        return json.get(fieldName).asText();
    }
183944
public static <T> void addIfNotNull(JSONWriter writer, String field,
			T value, JsonObjectWriter<T> objWriter) throws JSONException {
		if (value == null)
			return;
		writer.key(field);
		writer.object();
		objWriter.write(writer, value);
		writer.endObject();
	}
668902
@Deprecated
    public static <T> T jsonTo( String json, TypeReference<T> typeRef ) {
        return util.stringToType( json, typeRef );
    }
319104
@Override
	public void toPDB(StringBuffer buf){
		 Formatter formatter = new Formatter(new StringBuilder(),Locale.UK);
//        DBREF  3ETA A  990  1295  UNP    P06213   INSR_HUMAN    1017   1322
//        DBREF  3EH2 A    2   767  UNP    P53992   SC24C_HUMAN    329   1094
//        DBREF 3EH2 A    2   767     UNP   P53992  SC24C_HUMAN   329   1094
//        DBREF  3ETA A  990  1295  UNP    P06213   INSR_HUMAN    1017   1322
		formatter.format("DBREF  %4s %1s %4d%1s %4d%1s %-6s %-8s %-12s%6d%1c%6d%1c            ",
				idCode, chainName,seqbegin,insertBegin,seqEnd,insertEnd,
				database,dbAccession,dbIdCode,
				dbSeqBegin,idbnsBegin,dbSeqEnd,idbnsEnd
				);

		buf.append(formatter.toString());
		formatter.close();

	}
529056
private void toPrettyString(int indentLevel, StringBuilder buf) {
    for (int i = 0; i < indentLevel; i++) {
      buf.append("  ");
    }
    buf.append(shortName).append(": ").append(targetPatterns);
    for (GrammaticalRelation child : children) {
      buf.append('\n');
      child.toPrettyString(indentLevel + 1, buf);
    }
  }