// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/json/SimpleJSONParser.java
// public enum S {
//     AWAIT_BEGIN_COMMENT,
//     IN_COMMENT,
//     IN_LINE_COMMENT,
//     IN_KEY,
//     IN_VALUE,
//     IN_NUMERIC_VALUE,
//     IN_BOOLEAN_VALUE,
//     IN_ARRAY_ELEMENT,
//     IN_BOOLEAN_ARRAY_ELEMENT,
//     IN_NUMERIC_ARRAY_ELEMENT,
//     BEGIN,
//     AWAITING_KEY,
//     AWAITING_COMPOUND_VALUE,
//     AWAITING_ARRAY_ELEMENT,
//     AFTER_ARRAY_ELEMENT,
//     BETWEEN_KEY_AND_VALUE,
//     AWAITING_VALUE,
//     AFTER_VALUE;
// 
//     boolean isAwaitState () {
//         switch ( this ) {
//             case AWAITING_ARRAY_ELEMENT:
//             case AWAITING_VALUE:
//                 return true;
//         }
//         return false;
//     }
// }


import static org.netbeans.modules.nodejs.json.SimpleJSONParser.S.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Utilities;
    }

    public Map<String, Object> parse ( InputStream in ) throws JsonException, IOException {
        return parse( in, "UTF-8" );
    }

    public Map<String, Object> parse ( InputStream in, String encoding ) throws JsonException, IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        FileUtil.copy( in, out );
        String data = encoding == null ? new String( out.toByteArray() ) : new String( out.toByteArray(), encoding );
        return parse( data );
    }

    public Map<String, Object> parse ( CharSequence seq ) throws JsonException {
        CharVisitor v = new CharVisitor();
        State state = new State();
        int len = seq.length();
        int line = 0;
        for (int i = 0; i < len; i++) {
            char c = seq.charAt( i );
            if (c == '\n') {
                line++;
            }
            v.visitChar( c, i, line, state );
        }
        return state.map;
    }

    private final class CharVisitor {
        StringBuilder sb = new StringBuilder();
// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/json/SimpleJSONParser.java
// public enum S {
//     AWAIT_BEGIN_COMMENT,
//     IN_COMMENT,
//     IN_LINE_COMMENT,
//     IN_KEY,
//     IN_VALUE,
//     IN_NUMERIC_VALUE,
//     IN_BOOLEAN_VALUE,
//     IN_ARRAY_ELEMENT,
//     IN_BOOLEAN_ARRAY_ELEMENT,
//     IN_NUMERIC_ARRAY_ELEMENT,
//     BEGIN,
//     AWAITING_KEY,
//     AWAITING_COMPOUND_VALUE,
//     AWAITING_ARRAY_ELEMENT,
//     AFTER_ARRAY_ELEMENT,
//     BETWEEN_KEY_AND_VALUE,
//     AWAITING_VALUE,
//     AFTER_VALUE;
// 
//     boolean isAwaitState () {
//         switch ( this ) {
//             case AWAITING_ARRAY_ELEMENT:
//             case AWAITING_VALUE:
//                 return true;
//         }
//         return false;
//     }
// }


// Path: node-projects/src/main/java/org/netbeans/modules/nodejs/json/SimpleJSONParser.java
import static org.netbeans.modules.nodejs.json.SimpleJSONParser.S.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Utilities;

    }

    public Map<String, Object> parse ( InputStream in ) throws JsonException, IOException {
        return parse( in, "UTF-8" );
    }

    public Map<String, Object> parse ( InputStream in, String encoding ) throws JsonException, IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        FileUtil.copy( in, out );
        String data = encoding == null ? new String( out.toByteArray() ) : new String( out.toByteArray(), encoding );
        return parse( data );
    }

    public Map<String, Object> parse ( CharSequence seq ) throws JsonException {
        CharVisitor v = new CharVisitor();
        State state = new State();
        int len = seq.length();
        int line = 0;
        for (int i = 0; i < len; i++) {
            char c = seq.charAt( i );
            if (c == '\n') {
                line++;
            }
            v.visitChar( c, i, line, state );
        }
        return state.map;
    }

    private final class CharVisitor {
        StringBuilder sb = new StringBuilder();
        S s = S.BEGIN;