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 04:28Andrew EpsteinAndrew EpsteinScore: 2,980Success
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 04:592,95437,847,67318,435,0008,455,00092,676,096
2Nov 3, 2026 04:592,95437,767,40618,415,0008,469,00092,749,824
3Nov 3, 2026 04:592,95837,777,89218,456,0008,463,00092,672,000
4Nov 3, 2026 04:592,96739,360,61918,484,0008,519,00092,774,400
5Nov 3, 2026 04:592,98038,493,32418,550,0008,576,00092,717,056
6Nov 3, 2026 04:592,99338,063,30618,588,0008,655,00092,737,536
7Nov 3, 2026 04:592,99638,145,40018,476,0008,790,00092,778,496
8Nov 3, 2026 04:592,99838,635,49318,600,0008,687,00092,766,208
9Nov 3, 2026 04:593,02550,825,25618,820,0008,715,00092,721,152