def loads(s):
    stack = []
    chars = iter(s)
    value = None
    currCharIsNext=False

    try:
        while(1):
            skip = False
            if not currCharIsNext:
                c = chars.next()
            while(c in [' ', '\t', '\r','\n']):
                c = chars.next()
            currCharIsNext=False
            if c=='"':
                value = ''
                try:
                    c=chars.next()
                    while c != '"':
                        if c == '\\':
                            c=chars.next()
                            try:
                                value+=EscapeCharToChar[c]
                            except KeyError:
                                if c == 'u':
                                    hexCode = chars.next() + chars.next() + chars.next() + chars.next()
                                    value += unichr(int(hexCode,16))
                                else:
                                    raise JSONDecodeException("Bad Escape Sequence Found")
                        else:
                            value+=c
                        c=chars.next()
                except StopIteration:
                    raise JSONDecodeException("Expected end of String")
            elif c == '{':
                stack.append({})
                skip=True
            elif c =='}':
                value = stack.pop()
            elif c == '[':
                stack.append([])
                skip=True
            elif c == ']':
                value = stack.pop()
            elif c in [',',':']:
                skip=True
            elif c in Digits or c == '-':
                digits=[c]
                c = chars.next()
                numConv = int
                try:
                    while c in Digits:
                        digits.append(c)
                        c = chars.next()
                    if c == ".":
                        numConv=float
                        digits.append(c)
                        c = chars.next()
                        while c in Digits:
                            digits.append(c)
                            c = chars.next()
                        if c.upper() == 'E':
                            digits.append(c)
                            c = chars.next()
                            if c in ['+','-']:
                                digits.append(c)
                                c = chars.next()
                                while c in Digits:
                                    digits.append(c)
                                    c = chars.next()
                            else:
                                raise JSONDecodeException("Expected + or -")
                except StopIteration:
                    pass
                value = numConv("".join(digits))
                currCharIsNext=True

            elif c in ['t','f','n']:
                kw = c+ chars.next() + chars.next() + chars.next()
                if kw == 'null':
                    value = None
                elif kw == 'true':
                    value = True
                elif kw == 'fals' and chars.next() == 'e':
                    value = False
                else:
                    raise JSONDecodeException('Expected Null, False or True')
            else:
                raise JSONDecodeException('Expected []{}," or Number, Null, False or True')

            if not skip:
                if len(stack):
                    top = stack[-1]
                    if type(top) is ListType:
                        top.append(value)
                    elif type(top) is DictionaryType:
                        stack.append(value)
                    elif type(top)  in StringTypes:
                        key = stack.pop()
                        stack[-1][key] = value
                    else:
                        raise JSONDecodeException("Expected dictionary key, or start of a value")
                else:
                    return value
    except __HOLE__:
         raise JSONDecodeException("Unexpected end of JSON source")
dataset/ETHPy150Open blinktrade/bitex/libs/jsonrpc/json.py/loads