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 3, 2026 09:37Andrew EpsteinAndrew EpsteinScore: 2,426Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 09:532,40331,201,57513,478,0008,395,00092,811,264
2Nov 3, 2026 09:532,40331,141,26713,333,0008,536,00092,737,536
3Nov 3, 2026 09:532,41732,691,18913,448,0008,549,00092,733,440
4Nov 3, 2026 09:532,41831,234,04713,499,0008,505,00092,803,072
5Nov 3, 2026 09:532,42633,412,98413,479,0008,599,00092,692,480
6Nov 3, 2026 09:532,42731,335,69413,485,0008,602,00092,729,344
7Nov 3, 2026 09:532,42931,413,34813,569,0008,541,00092,753,920
8Nov 3, 2026 09:532,43031,455,09713,372,0008,743,00092,721,152
9Nov 3, 2026 09:532,43431,435,91813,514,0008,644,00092,725,248