XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listNov 5, 2026 05:07Andrew EpsteinAndrew EpsteinScore: 2,407Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 05:562,37330,843,24513,024,0008,571,00092,745,728
2Nov 5, 2026 05:562,37430,843,72213,087,0008,517,00092,680,192
3Nov 5, 2026 05:562,37830,840,13413,121,0008,519,00092,729,344
4Nov 5, 2026 05:562,39131,037,63413,248,0008,517,00092,798,976
5Nov 5, 2026 05:562,40731,069,54513,326,0008,585,00092,753,920
6Nov 5, 2026 05:562,40930,731,51113,315,0008,612,00092,733,440
7Nov 5, 2026 05:562,41631,251,63913,320,0008,674,00092,717,056
8Nov 5, 2026 05:562,41831,330,06113,311,0008,701,00092,737,536
9Nov 5, 2026 05:562,42731,318,94613,389,0008,703,00092,737,536