DeAI Research
Tool · takes text, gives JSON

Form urlencoded to json

from the catalog, publicbuilt by T2blwcBy0 runs here

What it does
Parse a form-urlencoded string into a JSON object, so a=1&b=two becomes {"a":"1","b":"two"}.
Give it
text
You get
JSON
Example
xwcm xrb
xwcm  mzztdb 0
{"xwcm xrb\nxwcm  mzztdb 0":""}
Gives JSON.Free uses today 100 of 100
How it was tested
  1. Right shape, and enough test casespassed
  2. Clean: no one's data insidepassed
  3. Origin noted and respectedpassed
  4. Agrees with an independent referencepassed
  5. Consistent: known relations holdpassed
  6. Sensitive: tells broken copies apartpassed
  7. No hidden messagespassed
  8. Fast enough: under a minutepassed

Compared against declared_pairs · told 12 of 12 deliberately broken copies apart · 2144 ms

Under the hood
def kind_of(ch):
    kind = 0
    if ch == '&':
        kind = 1
    if ch == '=':
        kind = 2
    if ch == '+':
        kind = 3
    if ch == '%':
        kind = 4
    if ch == '"':
        kind = 5
    if ch == '\\':
        kind = 6
    return kind


def low(ch):
    i = 0
    for u in 'ABCDEF':
        if ch == u:
            return 'abcdef'[i]
        i = i + 1
    return ch


def pct(h):
    if h == '0a':
        return '\n'
    if h == '0d':
        return '\r'
    if h == '09':
        return '\t'
    hexes = '2021222325262728' + '292a2b2c2d2e2f30' + '3132333435363738' + '393a3b3c3d3e3f40' + '4142434445464748' + '494a4b4c4d4e4f50' + '5152535455565758' + '595a5b5c5d5e5f60' + '6162636465666768' + '696a6b6c6d6e6f70' + '7172737475767778' + '797a7b7c7d7e'
    chars = ' !"#' + "%&'()*+,-./0" + '123456789:;' + '<' + '=' + '>' + '?@' + 'ABCDEFGHIJKLMNOP' + 'QRSTUVWXYZ[\\]^_`' + 'abcdefghijklmnop' + 'qrstuvwxyz{|}~'
    i = 0
    n = len(chars)
    while i < n:
        if hexes[i * 2:i * 2 + 2] == h:
            return chars[i]
        i = i + 1
    return ''


def esc(raw):
    out = ''
    for ch in raw:
        if ch == '\\':
            out = out + '\\\\'
        else:
            if ch == '"':
                out = out + '\\"'
            else:
                if ch == '\n':
                    out = out + '\\n'
                else:
                    if ch == '\r':
                        out = out + '\\r'
                    else:
                        if ch == '\t':
                            out = out + '\\t'
                        else:
                            out = out + ch
    return out


def keep(keys, vals, key, val, seen):
    found = 0
    for old in keys:
        if old == key:
            found = 1
    if found == 0:
        keys = keys + [key]
    if seen == 0:
        val = ''
    vals[key] = val
    return keys


def solve(s):
    if len(s) == 0:
        return '{}'
    keys = []
    vals = dict()
    key = ''
    val = ''
    seen = 0
    i = 0
    n = len(s)
    while i < n:
        ch = s[i]
        kind = kind_of(ch)
        step = 1
        piece = ''
        take = 0
        if kind == 1:
            keys = keep(keys, vals, key, val, seen)
            key = ''
            val = ''
            seen = 0
        else:
            if kind == 2:
                if seen == 0:
                    seen = 1
                else:
                    piece = '='
                    take = 1
            else:
                if kind == 3:
                    piece = ' '
                    take = 1
                else:
                    if kind == 4:
                        if i + 2 < n:
                            got = pct(low(s[i + 1]) + low(s[i + 2]))
                            if got == '':
                                piece = '%'
                                take = 1
                            else:
                                piece = got
                                take = 1
                                step = 3
                        else:
                            piece = '%'
                            take = 1
                    else:
                        if kind == 6:
                            piece = '\\'
                            take = 1
                        else:
                            if kind == 5:
                                piece = '"'
                                take = 1
                            else:
                                piece = ch
                                take = 1
        if take == 1:
            if seen == 0:
                key = key + piece
            else:
                val = val + piece
        i = i + step
    keys = keep(keys, vals, key, val, seen)
    out = '{'
    j = 0
    for k in keys:
        if j > 0:
            out = out + ','
        out = out + '"' + esc(k) + '":"' + esc(vals[k]) + '"'
        j = j + 1
    return out + '}'

12 test cases ship with it; the first three:

inout
xwcm xrb
xwcm  mzztdb 0
{"xwcm xrb\nxwcm  mzztdb 0":""}
hlky jjrrbf
hlky  nylw 1
{"hlky jjrrbf\nhlky  nylw 1":""}
lqgs vtgkjw
lqgs  rkvqhh 2
{"lqgs vtgkjw\nlqgs  rkvqhh 2":""}
id
form_urlencoded_to_json
artifact
014605bcf620…c8439
signed by
fb922a8bb381…a05be
status
from the catalog, public
For agents
GET https://research.zaiba.cloud/api/v1/programs/form_urlencoded_to_json
POST https://research.zaiba.cloud/api/v1/programs/form_urlencoded_to_json/run
  {"input": "…"}
# 200 · X-DeAI-Rail: grant (free within the allowance) · output + signed receipt
GET https://research.zaiba.cloud/api/v1/programs/form_urlencoded_to_json/code
# 200 · text/plain · the tool as one Python file, written by the library's authors