congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JsonWriter
Code IndexAdd Tabnine to your IDE (free)

How to use
JsonWriter
in
org.hjson

Best Java code snippets using org.hjson.JsonWriter (Showing top 14 results out of 315)

origin: org.hjson/hjson

static String escapeString(String src) {
 if (src==null) return null;
 for (int i=0; i<src.length(); i++) {
  if (getEscapedChar(src.charAt(i))!=null) {
   StringBuilder sb=new StringBuilder();
   if (i>0) sb.append(src, 0, i);
   return doEscapeString(sb, src, i);
  }
 }
 return src;
}
origin: org.hjson/hjson

static String escapeName(String name) {
 if (name.length()==0 || needsEscapeName.matcher(name).find())
  return "\""+JsonWriter.escapeString(name)+"\"";
 else
  return name;
}
origin: org.hjson/hjson

case OBJECT:
 JsonObject obj=value.asObject();
 if (obj.size()>0) nl(tw, level);
 tw.write('{');
 for (JsonObject.Member pair : obj) {
  if (following) tw.write(",");
  nl(tw, level+1);
  tw.write('\"');
  tw.write(escapeString(pair.getName()));
  tw.write("\":");
  if (format && vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) tw.write(" ");
  if (v==null) tw.write("null");
  else save(v, tw, level+1);
  following=true;
 if (following) nl(tw, level);
 tw.write('}');
 break;
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (n>0) nl(tw, level);
 tw.write('[');
 for (int i=0; i<n; i++) {
  JsonValue v=arr.get(i);
  JsonType vType=v.getType();
  if (vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) nl(tw, level+1);
origin: org.hjson/hjson

/**
 * Writes the JSON/Hjson representation of this value to the given writer using the given formatting.
 * <p>
 * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}.
 * </p>
 *
 * @param writer the writer to write this value to
 * @param format controls the formatting
 * @throws IOException if an I/O error occurs in the writer
 */
public void writeTo(Writer writer, Stringify format) throws IOException {
 WritingBuffer buffer=new WritingBuffer(writer, 128);
 switch (format) {
  case PLAIN: new JsonWriter(false).save(this, buffer, 0); break;
  case FORMATTED: new JsonWriter(true).save(this, buffer, 0); break;
  case HJSON: new HjsonWriter(null).save(this, buffer, 0, "", true); break;
 }
 buffer.flush();
}
origin: hjson/hjson-java

private static String doEscapeString(StringBuilder sb, String src, int cur) {
 int start=cur;
 for (int i=cur; i<src.length(); i++) {
  String escaped=getEscapedChar(src.charAt(i));
  if (escaped!=null) {
   sb.append(src, start, i);
   sb.append(escaped);
   start=i+1;
  }
 }
 sb.append(src, start, src.length());
 return sb.toString();
}
origin: hjson/hjson-java

case OBJECT:
 JsonObject obj=value.asObject();
 if (obj.size()>0) nl(tw, level);
 tw.write('{');
 for (JsonObject.Member pair : obj) {
  if (following) tw.write(",");
  nl(tw, level+1);
  tw.write('\"');
  tw.write(escapeString(pair.getName()));
  tw.write("\":");
  if (format && vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) tw.write(" ");
  if (v==null) tw.write("null");
  else save(v, tw, level+1);
  following=true;
 if (following) nl(tw, level);
 tw.write('}');
 break;
 JsonArray arr=value.asArray();
 int n=arr.size();
 if (n>0) nl(tw, level);
 tw.write('[');
 for (int i=0; i<n; i++) {
  JsonValue v=arr.get(i);
  JsonType vType=v.getType();
  if (vType!=JsonType.ARRAY && vType!=JsonType.OBJECT) nl(tw, level+1);
origin: hjson/hjson-java

/**
 * Writes the JSON/Hjson representation of this value to the given writer using the given formatting.
 * <p>
 * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}.
 * </p>
 *
 * @param writer the writer to write this value to
 * @param format controls the formatting
 * @throws IOException if an I/O error occurs in the writer
 */
public void writeTo(Writer writer, Stringify format) throws IOException {
 WritingBuffer buffer=new WritingBuffer(writer, 128);
 switch (format) {
  case PLAIN: new JsonWriter(false).save(this, buffer, 0); break;
  case FORMATTED: new JsonWriter(true).save(this, buffer, 0); break;
  case HJSON: new HjsonWriter(null).save(this, buffer, 0, "", true); break;
 }
 buffer.flush();
}
origin: org.hjson/hjson

private static String doEscapeString(StringBuilder sb, String src, int cur) {
 int start=cur;
 for (int i=cur; i<src.length(); i++) {
  String escaped=getEscapedChar(src.charAt(i));
  if (escaped!=null) {
   sb.append(src, start, i);
   sb.append(escaped);
   start=i+1;
  }
 }
 sb.append(src, start, src.length());
 return sb.toString();
}
origin: hjson/hjson-java

static String escapeString(String src) {
 if (src==null) return null;
 for (int i=0; i<src.length(); i++) {
  if (getEscapedChar(src.charAt(i))!=null) {
   StringBuilder sb=new StringBuilder();
   if (i>0) sb.append(src, 0, i);
   return doEscapeString(sb, src, i);
  }
 }
 return src;
}
origin: hjson/hjson-java

static String escapeName(String name) {
 if (name.length()==0 || needsEscapeName.matcher(name).find())
  return "\""+JsonWriter.escapeString(name)+"\"";
 else
  return name;
}
origin: org.hjson/hjson

static String escapeName(String name) {
 boolean needsEscape=name.length()==0;
 for(char ch : name.toCharArray()) {
  if (HjsonParser.isWhiteSpace(ch) || ch=='{' || ch=='}' || ch=='[' || ch==']' || ch==',' || ch==':') {
   needsEscape=true;
   break;
  }
 }
 if (needsEscape) return "\""+JsonWriter.escapeString(name)+"\"";
 else return name;
}
origin: hjson/hjson-java

static String escapeName(String name) {
 boolean needsEscape=name.length()==0;
 for(char ch : name.toCharArray()) {
  if (HjsonParser.isWhiteSpace(ch) || ch=='{' || ch=='}' || ch=='[' || ch==']' || ch==',' || ch==':') {
   needsEscape=true;
   break;
  }
 }
 if (needsEscape) return "\""+JsonWriter.escapeString(name)+"\"";
 else return name;
}
origin: org.hjson/hjson

else tw.write(separator+"\""+JsonWriter.escapeString(value)+"\"");
origin: hjson/hjson-java

else tw.write(separator+"\""+JsonWriter.escapeString(value)+"\"");
org.hjsonJsonWriter

Most used methods

  • <init>
  • doEscapeString
  • escapeString
  • getEscapedChar
  • nl
  • save

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now