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

How to use
JsonParser
in
org.hjson

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

origin: org.hjson/hjson

/**
 * Reads a JSON value from the given reader.
 * <p>
 * Characters are read in chunks and buffered internally, therefore wrapping an existing reader in
 * an additional <code>BufferedReader</code> does <strong>not</strong> improve reading
 * performance.
 * </p>
 *
 * @param reader the reader to read the JSON value from
 * @return the JSON value that has been read
 * @throws IOException if an I/O error occurs in the reader
 * @throws ParseException if the input is not valid JSON
 */
public static JsonValue readJSON(Reader reader) throws IOException {
 return new JsonParser(reader).parse();
}
origin: hjson/hjson-java

JsonValue parse() throws IOException {
 read();
 skipWhiteSpace();
 JsonValue result=readValue();
 skipWhiteSpace();
 if (!isEndOfText()) throw error("Unexpected character");
 return result;
}
origin: org.hjson/hjson

private boolean readFraction() throws IOException {
 if (!readIf('.')) {
  return false;
 }
 if (!readDigit()) {
  throw expected("digit");
 }
 while (readDigit()) {
 }
 return true;
}
origin: org.hjson/hjson

private void readRequiredChar(char ch) throws IOException {
 if (!readIf(ch)) {
  throw expected("'"+ch+"'");
 }
}
origin: org.hjson/hjson

private ParseException expected(String expected) {
 if (isEndOfText()) {
  return error("Unexpected end of input");
 }
 return error("Expected "+expected);
}
origin: org.hjson/hjson

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 do {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
 } while (readIf(','));
 if (!readIf(']')) {
  throw expected("',' or ']'");
 }
 return array;
}
origin: org.hjson/hjson

private JsonValue readValue() throws IOException {
 switch(current) {
  case 'n':
   return readNull();
  case 't':
   return readTrue();
  case 'f':
   return readFalse();
  case '"':
   return readString();
  case '[':
   return readArray();
  case '{':
   return readObject();
  case '-':
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
   return readNumber();
  default:
   throw expected("value");
 }
}
origin: org.hjson/hjson

private JsonValue readNumber() throws IOException {
 startCapture();
 readIf('-');
 int firstDigit=current;
 if (!readDigit()) {
  throw expected("digit");
 }
 if (firstDigit!='0') {
  while (readDigit()) {
  }
 }
 readFraction();
 readExponent();
 return new JsonNumber(Double.parseDouble(endCapture()));
}
origin: org.hjson/hjson

private String readStringInternal() throws IOException {
 read();
 startCapture();
 while (current!='"') {
  if (current=='\\') {
   pauseCapture();
   readEscape();
   startCapture();
  } else if (current<0x20) {
   throw expected("valid string character");
  } else {
   read();
  }
 }
 String string=endCapture();
 read();
 return string;
}
origin: org.hjson/hjson

private void readEscape() throws IOException {
 read();
 switch(current) {
  case '"':
   char[] hexChars=new char[4];
   for(int i=0; i<4; i++) {
    read();
    if (!isHexDigit()) {
     throw expected("hexadecimal digit");
   break;
  default:
   throw expected("valid escape sequence");
 read();
origin: org.hjson/hjson

private void skipWhiteSpace() throws IOException {
 while (isWhiteSpace()) {
  read();
 }
}
origin: hjson/hjson-java

private String readName() throws IOException {
 if (current!='"') {
  throw expected("name");
 }
 return readStringInternal();
}
origin: hjson/hjson-java

private boolean readDigit() throws IOException {
 if (!isDigit()) {
  return false;
 }
 read();
 return true;
}
origin: org.hjson/hjson

private ParseException error(String message) {
 int absIndex=bufferOffset+index;
 int column=absIndex-lineOffset;
 int offset=isEndOfText() ? absIndex : absIndex-1;
 return new ParseException(message, offset, line, column-1);
}
origin: hjson/hjson-java

private JsonArray readArray() throws IOException {
 read();
 JsonArray array=new JsonArray();
 skipWhiteSpace();
 if (readIf(']')) {
  return array;
 }
 do {
  skipWhiteSpace();
  array.add(readValue());
  skipWhiteSpace();
 } while (readIf(','));
 if (!readIf(']')) {
  throw expected("',' or ']'");
 }
 return array;
}
origin: hjson/hjson-java

private JsonValue readValue() throws IOException {
 switch(current) {
  case 'n':
   return readNull();
  case 't':
   return readTrue();
  case 'f':
   return readFalse();
  case '"':
   return readString();
  case '[':
   return readArray();
  case '{':
   return readObject();
  case '-':
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
   return readNumber();
  default:
   throw expected("value");
 }
}
origin: hjson/hjson-java

private JsonValue readNumber() throws IOException {
 startCapture();
 readIf('-');
 int firstDigit=current;
 if (!readDigit()) {
  throw expected("digit");
 }
 if (firstDigit!='0') {
  while (readDigit()) {
  }
 }
 readFraction();
 readExponent();
 return new JsonNumber(Double.parseDouble(endCapture()));
}
origin: hjson/hjson-java

private String readStringInternal() throws IOException {
 read();
 startCapture();
 while (current!='"') {
  if (current=='\\') {
   pauseCapture();
   readEscape();
   startCapture();
  } else if (current<0x20) {
   throw expected("valid string character");
  } else {
   read();
  }
 }
 String string=endCapture();
 read();
 return string;
}
origin: hjson/hjson-java

private void readEscape() throws IOException {
 read();
 switch(current) {
  case '"':
   char[] hexChars=new char[4];
   for(int i=0; i<4; i++) {
    read();
    if (!isHexDigit()) {
     throw expected("hexadecimal digit");
   break;
  default:
   throw expected("valid escape sequence");
 read();
origin: hjson/hjson-java

private void readRequiredChar(char ch) throws IOException {
 if (!readIf(ch)) {
  throw expected("'"+ch+"'");
 }
}
org.hjsonJsonParser

Most used methods

  • <init>
  • endCapture
  • error
  • expected
  • isDigit
  • isEndOfText
  • isHexDigit
  • isWhiteSpace
  • parse
  • pauseCapture
  • read
  • readArray
  • read,
  • readArray,
  • readDigit,
  • readEscape,
  • readExponent,
  • readFalse,
  • readFraction,
  • readIf,
  • readName,
  • readNull

Popular in Java

  • Making http post requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setScale (BigDecimal)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JList (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Runner (org.openjdk.jmh.runner)
  • Best IntelliJ 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