package edu.grinnell.callaway;

import java.io.BufferedReader;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Vector;

public class JSON2
{
  public Object parse(String str)
    throws Exception
  {
    BufferedReader text = new BufferedReader(new StringReader(str));
    return this.parse(text);
  }

  public Object parse(BufferedReader str)
    throws Exception
  {
    int c;
    Object result;
    while ((c = str.read()) != -1)
      {
        switch (c)
          {
          // ignore whitespace chars
            case ' ':
            case '\n':
            case '\t':
            case '\r':
            case '\b':
            case '\f':
              break;
            // object
            case '{':
              result = parseObject(str);
              break;
            // array
            case '[':
              result = parseArray(str);
              break;
            // string
            case '\\':
              int next = str.read();
              if (next == '"')
                {
                result = parseString(str);
                }
              else
                {
                  throw new Exception("Invalid character " + next);
                }
              break;
            // true
            case 't':
              ;
              //= str.read(cbuf)
              result = null;
              break;
            // false
            case 'f':
              result = null;
              break;
            // null
            case 'n':
              result = null;
              break;
            // number
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':

              break;
            // otherwise error
            default:

              throw new Exception("");
          }
      }
    return result;
  }

  public Object parseArray(BufferedReader str) throws Exception
  {
    Vector<Object> array= new Vector<Object>();
    
    parse(str.substring(1));
    int c;
   while((c =str.read())!= ']'){
      switch (c){
        
        
   }
    
   
    

          }
      }

  }


@@ -1035,32 +1035,34 @@
                 
+  
 result = parseSt
@@ -1294,27 +1294,53 @@
     
-;%0A              //=
+if (str.read() == 'r' && str.read() == 'u' &&
  str
@@ -1349,12 +1349,16 @@
 ead(
-cbuf
+) == 'e'
 )%0A  
@@ -1373,207 +1373,819 @@
     
-result = null;%0A              break;%0A            // false%0A            case 'f':%0A              result = null;%0A              break;%0A            // null%0A            case 'n':%0A              result = null;
+  %7B%0A                  result = true;%0A                %7D%0A              else%0A                %7B%0A                  throw new Exception(%22%22);%0A                %7D%0A              break;%0A            // false%0A            case 'f':%0A              if (str.read() == 'a' && str.read() == 'l' && str.read() == 's'%0A                  && str.read() == 'e')%0A                %7B%0A                  result = false;%0A                %7D%0A              else%0A                %7B%0A                  throw new Exception(%22%22);%0A                %7D%0A              break;%0A            // null%0A            case 'n':%0A              if (str.read() == 'u' && str.read() == 'l' && str.read() == 'l')%0A                %7B%0A                  result = null;%0A                %7D%0A              else%0A                %7B%0A                  throw new Exception(%22%22);%0A                %7D
 %0A   
@@ -2444,16 +2444,126 @@
 se '9':%0A
+              StringBuilder numString = new StringBuilder();%0A              numString.append(c);%0A              
 %0A       
@@ -2758,16 +2758,20 @@
 der str)
+%0A   
  throws 
@@ -2808,16 +2808,17 @@
 t%3E array
+ 
 = new Ve
@@ -2837,61 +2837,66 @@
 ();%0A
+%0A
     
-%0A    parse(str.substring
+int c;%0A    str.mark
 (1)
-)
 ;%0A    
-int c
+c = str.read()
 ;%0A
+ 
    while
 ((c 
@@ -2895,100 +2895,414 @@
 hile
-((c =str.read())!= '%5D')%7B%0A      switch (c)%7B%0A        %0A        %0A   %7D%0A    %0A   %0A    %0A%0A          %7D
+ (c != '%5D')%0A      %7B%0A        switch (c)%0A          %7B%0A          // ignore whitespace chars%0A            case ' ':%0A            case '%5Cn':%0A            case '%5Ct':%0A            case '%5Cr':%0A            case '%5Cb':%0A            case '%5Cf':%0A              break;%0A            default:%0A              str.reset();%0A              // add to array%0A              parse(str);%0A          %7D%0A        str.mark(1);%0A        c = str.read();
 %0A   
@@ -3306,14 +3306,15 @@
       %7D%0A
-%0A
   %7D%0A%0A
+%7D%0A

write parseArray structure