code: public JSONObject parseObject(boolean ordered) throws IOException {
          JSONObject result = null;
  
          if (!ordered)
          {
              result = new JSONObject();
          }
          else
          {
              result = new OrderedJSONObject();
          }
  
          if (lastToken != Token.TokenBraceL) throw new IOException("Expecting '{' " + tokenizer.onLineCol() + " instead, obtained token: '" + lastToken + "'");
          lastToken = tokenizer.next();
  
          while (true)
          {
              if (lastToken == Token.TokenEOF) throw new IOException("Unterminated object " + tokenizer.onLineCol());
  
              if (lastToken == Token.TokenBraceR)
              {
                  lastToken = tokenizer.next();
                  break;
              }
  
              if (!lastToken.isString()) throw new IOException("Expecting string key " + tokenizer.onLineCol());
              String key = lastToken.getString();
  
              lastToken = tokenizer.next();
              if (lastToken != Token.TokenColon) throw new IOException("Expecting colon " + tokenizer.onLineCol());
  
              lastToken = tokenizer.next();
              Object val = parseValue(ordered);
  
              result.put(key, val);
  
              if (lastToken == Token.TokenComma)
              {
                  lastToken = tokenizer.next();
              }
  
              else if (lastToken != Token.TokenBraceR)
              {
                  throw new IOException("expecting either ',' or '}' " + tokenizer.onLineCol());
              }
          }
  
          return result;
      }
docs: Method to parse a JSON object out of the current JSON string position.
  @param ordered Flag to denote if the parse should contruct a JSON object which maintains serialization order of the attributes.
  @return JSONObject Returns the parsed out JSON object.
  
  @throws IOException Thrown if an IO error occurs during parse, such as a malformed JSON object.