Removes all non JavaIdentifier chars from the start of the string.

@throws JSONException if the resulting string has zero length.
434283
protected final String shaveOffNonJavaIdentifierStartChars( String str ) {
      String str2 = str;
      // shave off first char if not valid
      boolean ready = false;
      while( !ready ){
         if( !Character.isJavaIdentifierStart( str2.charAt( 0 ) ) ){
            str2 = str2.substring( 1 );
            if( str2.length() == 0 ){
               throw new JSONException( "Can't convert '" + str + "' to a valid Java identifier" );
            }
         }else{
            ready = true;
         }
      }
      return str2;
   }
473580
public String next(int n) throws JSONException {
		if (n == 0) {
			return "";
		}

		char[] chars = new char[n];
		int pos = 0;
		while (pos < n) {
			chars[pos] = this.next();
			if (this.end()) {
				throw this.syntaxError("Substring bounds error");
			}
			pos += 1;
		}
		return new String(chars);
	}
708697
private JsonToken decodeNumber(char[] chars, int offset, int length) {
        int i = offset;
        int c = chars[i];

        if (c == '-') {
            c = chars[++i];
        }

        if (c == '0') {
            c = chars[++i];
        } else if (c >= '1' && c <= '9') {
            c = chars[++i];
            while (c >= '0' && c <= '9') {
                c = chars[++i];
            }
        } else {
            return JsonToken.STRING;
        }

        if (c == '.') {
            c = chars[++i];
            while (c >= '0' && c <= '9') {
                c = chars[++i];
            }
        }

        if (c == 'e' || c == 'E') {
            c = chars[++i];
            if (c == '+' || c == '-') {
                c = chars[++i];
            }
            if (c >= '0' && c <= '9') {
                c = chars[++i];
                while (c >= '0' && c <= '9') {
                    c = chars[++i];
                }
            } else {
                return JsonToken.STRING;
            }
        }

        if (i == offset + length) {
            return JsonToken.NUMBER;
        } else {
            return JsonToken.STRING;
        }
    }
785938
private void jsonEscape(StringBuilder sb, String s) {
        if (s == null) {
            sb.append(s);
            return;
        }
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            switch (c) {
                case '\b':
                    sb.append("\\b");
                    break;
                case '\f':
                    sb.append("\\f");
                    break;
                case '\n':
                    sb.append("\\n");
                    break;
                case '\r':
                    sb.append("\\r");
                    break;
                case '\t':
                    sb.append("\\t");
                    break;

                // Fall through because we just need to add \ (escaped) before the character
                case '\\':
                case '\"':
                case '/':
                    sb.append("\\");
                    sb.append(c);
                    break;
                default:
                    sb.append(c);
            }
        }
    }
952808
private void stripTrailingDelimiters(StringBuilder buffer)
   {
      int index = buffer.length() - 1;

      while (index > 0 && buffer.charAt(index) == m_delimiter)
      {
         --index;
      }

      buffer.setLength(index + 1);
   }
1134709
function removeUnwantedCharacters(cleanedString, unwantedCharArray) {
    for (var x = 0; x < unwantedCharArray.length; x++) {
        var unwantedCharRegExp = new RegExp(unwantedCharArray[x], 'g');
        cleanedString = cleanedString.replace(unwantedCharRegExp, '');
    }
    return cleanedString;
}
533285
public static String getString(JSONValue value) {
        if (value == null)
            return null;
        if (!(value instanceof JSONString))
            throw new JSONException(NOT_A_STRING);
        return ((JSONString)value).toString();
    }
1091234
public int skipWhitespace() {
        try {
            int readChar = 20;
            char c = SPACE;
            while (Character.isWhitespace(c)) {
                reader.mark(1);
                readChar = reader.read();
                c = (char) readChar;
            }
            reader.reset();
            return readChar;
        } catch (IOException ioe) {
            throw new JsonException("An IO exception occurred while reading the JSON payload", ioe);
        }
    }
473295
public static final String format(String json) {
		final int len = json.length();
		if (len < 3) {
			return json;
		}
		final StringTokenizer st = new StringTokenizer(json, ",{}[]", true);
		final StringBuilder out = new StringBuilder(len * 2);
		String token;
		int indent = 0;
		while (st.hasMoreTokens()) {
			token = st.nextToken();
			if ("{".equals(token) || "[".equals(token)) {
				indent++;
				out.append(token);
				appendIndent(out, indent);
				continue;
			}
			if ("}".equals(token) || "]".equals(token)) {
				indent--;
				appendIndent(out, indent);
				out.append(token);
				continue;
			}
			if (",".equals(token)) {
				out.append(',');
				appendIndent(out, indent);
				continue;
			}
			out.append(token);
		}
		return out.toString();
	}
944948
public static boolean isValidJavaIdentifier(String str) {
    if (isNullOrEmpty(str)) {
      return false;
    }
    if (JAVA_KEYWORDS.contains(str)) {
      return false;
    }
    if (!Character.isJavaIdentifierStart(str.charAt(0))) {
      return false;
    }
    for (int i = 1; i < str.length(); i++) {
      if (!Character.isJavaIdentifierPart(str.charAt(i))) {
        return false;
      }
    }
    return true;
  }
326042
@Override
    public final T deserializeInline( final JsonReader reader, final JsonDeserializationContext ctx, JsonDeserializerParameters params,
                                      IdentityDeserializationInfo identityInfo, TypeDeserializationInfo typeInfo, String type,
                                      Map<String, String> bufferedProperties ) {
        final boolean ignoreUnknown = params.isIgnoreUnknown() || isDefaultIgnoreUnknown();
        final Set<String> ignoredProperties;
        if ( null == params.getIgnoredProperties() ) {
            ignoredProperties = defaultIgnoredProperties;
        } else {
            ignoredProperties = new HashSet<String>( defaultIgnoredProperties );
            ignoredProperties.addAll( params.getIgnoredProperties() );
        }

        // we will remove the properties read from this list and check at the end it's empty
        Set<String> requiredPropertiesLeft = requiredProperties.isEmpty() ? Collections
                .<String>emptySet() : new HashSet<String>( requiredProperties );

        // we first look for identity. It can also buffer properties if it is not in current reader position.
        Object id = null;
        Map<String, Object> bufferedPropertiesValues = null;
        if ( null != identityInfo ) {
            JsonReader identityReader = null;

            // we look if it has not been already buffered
            String propertyValue = null;

            // we fisrt look if the identity property has not been read already
            if ( null != bufferedProperties ) {
                propertyValue = bufferedProperties.remove( identityInfo.getPropertyName() );
            }

            if ( null != propertyValue ) {
                identityReader = ctx.newJsonReader( propertyValue );
            } else {
                // we search for the identity property
                while ( JsonToken.NAME.equals( reader.peek() ) ) {
                    String name = reader.nextName();

                    if ( ignoredProperties.contains( name ) ) {
                        reader.skipValue();
                        continue;
                    }

                    if ( identityInfo.getPropertyName().equals( name ) ) {
                        identityReader = reader;
                        break;
                    } else {
                        if ( null == bufferedProperties ) {
                            bufferedProperties = new HashMap<String, String>();
                        }
                        bufferedProperties.put( name, reader.nextValue() );
                    }
                }
            }

            if ( null != identityReader ) {
                if ( identityInfo.isProperty() ) {
                    HasDeserializerAndParameters propertyDeserializer = deserializers.get( identityInfo.getPropertyName() );
                    if ( null == propertyDeserializer ) {
                        // the identity property is defined in constructor
                        propertyDeserializer = instanceBuilder.getParametersDeserializer().get( identityInfo.getPropertyName() );
                        id = propertyDeserializer.getDeserializer().deserialize( identityReader, ctx );
                        bufferedPropertiesValues = new HashMap<String, Object>( 1 );
                        bufferedPropertiesValues.put( identityInfo.getPropertyName(), id );
                    } else {
                        id = propertyDeserializer.getDeserializer().deserialize( identityReader, ctx );
                    }
                } else {
                    id = identityInfo.readId( identityReader, ctx );
                }
            }
        }

        // we first instantiate the bean. It might buffer properties if there are properties required for constructor and they are not in
        // first position
        Instance<T> instance = instanceBuilder.newInstance( reader, ctx, params, bufferedProperties, bufferedPropertiesValues );

        T bean = instance.getInstance();
        bufferedProperties = instance.getBufferedProperties();

        // we save the instance if we have an id
        if ( null != id ) {
            if ( identityInfo.isProperty() ) {
                BeanPropertyDeserializer propertyDeserializer = deserializers.get( identityInfo.getPropertyName() );
                if ( null != propertyDeserializer ) {
                    propertyDeserializer.setValue( bean, id, ctx );
                }
            }
            ctx.addObjectId( identityInfo.newIdKey( id ), bean );
        }

        // we flush any buffered properties
        flushBufferedProperties( bean, bufferedProperties, requiredPropertiesLeft, ctx, ignoreUnknown, ignoredProperties );

        // in case there is a property that need the type info
        if ( null != typeInfo && null != typeInfo.getPropertyName() && null != type ) {
            BeanPropertyDeserializer deserializer = getPropertyDeserializer( typeInfo.getPropertyName(), ctx, true );
            if ( null != deserializer ) {
                deserializer.setValue( bean, type, ctx );
            }
        }

        while ( JsonToken.NAME.equals( reader.peek() ) ) {
            String propertyName = reader.nextName();

            requiredPropertiesLeft.remove( propertyName );

            if ( ignoredProperties.contains( propertyName ) ) {
                reader.skipValue();
                continue;
            }

            BeanPropertyDeserializer<T, ?> property = getPropertyDeserializer( propertyName, ctx, ignoreUnknown );
            if ( null != property ) {
                property.deserialize( reader, bean, ctx );
            } else if ( null != anySetterDeserializer ) {
                anySetterDeserializer.deserialize( reader, bean, propertyName, ctx );
            } else {
                reader.skipValue();
            }
        }

        if ( !requiredPropertiesLeft.isEmpty() ) {
            throw ctx.traceError( "Required properties are missing : " + requiredPropertiesLeft, reader );
        }
        return bean;
    }
1001523
public static int skipIdentifier(CharSequence s, int i) {
        while(i<s.length() && !isSyntaxOrWhiteSpace(s.charAt(i))) {
            ++i;
        }
        return i;
    }
545801
private void pop(char closer) throws JSONException {
        if (m_top <= -1) {
            throw new JSONException("Nesting error.");
        }
        try {
            m_writer.write(closer);
        }
        catch (IOException e) {
            throw new JSONException(e);
        }
        --m_top;
        m_mode = (m_top == -1) ?
                'd' :
                (m_scopeStack[m_top] == null) ? 'a' : 'k';
        m_expectingComma = true;
    }
1009220
private void writeString(String string) throws JSONException {

// Special case for empty strings.

        if (string.length() == 0) {
            zero();
            write(end, this.stringhuff);
        } else {
            Kim kim = new Kim(string);

// Look for the string in the strings keep. If it is found, emit its
// integer and count that as a use.

            int integer = this.stringkeep.find(kim);
            if (integer != none) {
                one();
                write(integer, this.stringkeep);
            } else {

// But if it is not found, emit the string's characters. Register the string
// so that a later lookup can succeed.

                zero();
                write(kim, this.stringhuff, this.stringhuffext);
                write(end, this.stringhuff);
                this.stringkeep.register(kim);
            }
        }
    }
948703
@Override
    public FastStr replace(char oldChar, char newChar) {
        if (oldChar != newChar) {
            char[] val = this.buf; /* avoid getfield opcode */
            int len = length();
            int i = begin - 1;

            while (++i < end) {
                if (val[i] == oldChar) {
                    break;
                }
            }
            if (i < end) {
                char buf[] = new char[len];
                for (int j = begin; j < i; j++) {
                    buf[j - begin] = val[j];
                }
                while (i < end) {
                    char c = val[i];
                    buf[i - begin] = (c == oldChar) ? newChar : c;
                    i++;
                }
                return new FastStr(buf, 0, len);
            }
        }
        return this;
    }
726099
private JSONWriter end(char mode, char c) throws JSONException {
        if (this.mode != mode) {
            throw new JSONException(mode == 'a'
                ? "Misplaced endArray."
                : "Misplaced endObject.");
        }
        this.pop(mode);
        try {
            this.writer.write(c);
        } catch (IOException e) {
            throw new JSONException(e);
        }
        this.comma = true;
        return this;
    }
621274
@Override
    public void clear() {
        _rows = 0;
        Arrays.fill(_value, null);
        Arrays.fill(_tree, (char) 0);
        Arrays.fill(_key, null);
    }