public JSONError parse(char [] js, List<JSONToken> tokens) {
		JSONError r;
		int i;
		JSONToken token;
		
		for (; pos < js.length; pos++) {
			char c ;
			JSONType type;
	
			c = js[pos];
			switch (c) {
				case '{': case '[':
					token = allocateToken(tokens,
							c == '{' ? JSONType.JSMN_OBJECT : JSONType.JSMN_ARRAY,
							pos, -1);
					if (toksuper != -1) {
						tokens.get(toksuper).incSize();
					}
					toksuper = toknext - 1;
					break;
				case '}': case ']':
					type = (c == '}' ? JSONType.JSMN_OBJECT : JSONType.JSMN_ARRAY);
					for (i = toknext - 1; i >= 0; i--) {
						token = tokens.get(i);
						if (token.start != -1 && token.end == -1) {
							if (token.type != type) {
								return JSONError.JSMN_ERROR_INVAL;
							}
							toksuper = -1;
							token.end = pos + 1;
							break;
						}
					}
					/* Error if unmatched closing bracket */
					if (i == -1) {
						return JSONError.JSMN_ERROR_INVAL;
					}
					for (; i >= 0; i--) {
						token = tokens.get(i);
						if (token.start != -1 && token.end == -1) {
							toksuper = i;
							break;
						}
					}
					break;
				case '\"':
					r = parseString(js, tokens);
					if (r != JSONError.JSMN_SUCCESS) return r;
					if (toksuper != -1) {
						tokens.get(toksuper).incSize();
					}
					break;
				case '\t' : case '\r' : case '\n' : case ':' : case ',': case ' ': 
					break;
				/* In strict mode primitives are: numbers and booleans */
				case '-': case '0': case '1' : case '2': case '3' : case '4':
				case '5': case '6': case '7' : case '8': case '9':
				case 't': case 'f': case 'n' :
					r = parsePrimitive(js, tokens);
					if (r != JSONError.JSMN_SUCCESS) return r;
					if (toksuper != -1)
						tokens.get(toksuper).incSize();
					break;
				/* In non-strict mode every unquoted value is a primitive */
				default:
					if (JSMN_STRICT) {
						r = parsePrimitive(js, tokens);
						if (r != JSONError.JSMN_SUCCESS) return r;
						if (toksuper != -1) {
							tokens.get(toksuper).incSize();
						}
					} else {
						return JSONError.JSMN_ERROR_INVAL;
					}
					break;
			}
		}
	
		for (i = toknext - 1; i >= 0; i--) {
			/* Unmatched opened object or array */
			JSONToken test = tokens.get(i);
			if (test.start != -1 && test.end == -1) {
				return JSONError.JSMN_ERROR_PART;
			}
		}
	
		return JSONError.JSMN_SUCCESS;
	}
Parse JSON string and fill tokens.
Ghidra/Framework/Generic/src/main/java/generic/json/JSONParser.java