def parse_string(i, json):
    j = i
    output = UnicodeBuilder()
    while True:
        c = json[j]
        if c == "\"":
            return j + 1, output.build()
        elif c == "\\":
            j += 1
            c = json[j]
            if c == "u":
                n = json[j:j + 4].decode('hex').decode('utf-8')
                output.append(n)
                j += 4
            else:
                try:
                    output.append(ESC[c])
                except Exception, e:
                    output.append("\\")
                    output.append(c)
        else:
            output.append(c)
        j += 1
Exemple #2
0
def parse_string(i, json):
    j = i
    output = UnicodeBuilder()
    while True:
        c = json[j]
        if c == "\"":
            return j + 1, output.build()
        elif c == "\\":
            j += 1
            c = json[j]
            if c == "u":
                n = json[j:j + 4].decode('hex').decode('utf-8')
                output.append(n)
                j += 4
            else:
                try:
                    output.append(ESC[c])
                except Exception, e:
                    output.append("\\")
                    output.append(c)
        else:
            output.append(c)
        j += 1