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 04:53Andrew EpsteinAndrew EpsteinScore: 2,451Success
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:182,41631,345,20013,641,0008,345,00092,733,440
2Nov 5, 2026 05:182,42231,332,88213,606,0008,440,00092,758,016
3Nov 5, 2026 05:182,43931,618,67213,562,0008,633,00092,721,152
4Nov 5, 2026 05:182,44131,543,80413,779,0008,435,00092,774,400
5Nov 5, 2026 05:182,45132,318,23913,853,0008,460,00092,708,864
6Nov 5, 2026 05:182,45331,692,28213,743,0008,587,00092,721,152
7Nov 5, 2026 05:182,45431,590,22913,836,0008,496,00092,712,960
8Nov 5, 2026 05:182,45831,613,20013,806,0008,565,00092,737,536
9Nov 5, 2026 05:182,46931,788,64813,894,0008,574,00092,766,208