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:50Andrew EpsteinAndrew EpsteinScore: 2,439Success
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 04:572,40831,298,52913,461,0008,453,00092,762,112
2Nov 5, 2026 04:572,41931,291,87613,374,0008,645,00092,762,112
3Nov 5, 2026 04:572,42631,457,25013,582,0008,500,00092,659,712
4Nov 5, 2026 04:572,43731,522,38313,690,0008,494,00092,725,248
5Nov 5, 2026 04:572,43931,561,17613,720,0008,479,00092,745,728
6Nov 5, 2026 04:572,44331,515,52713,766,0008,470,00092,753,920
7Nov 5, 2026 04:572,44931,521,50513,730,0008,558,00092,680,192
8Nov 5, 2026 04:572,46631,743,87713,824,0008,623,00092,712,960
9Nov 5, 2026 04:572,53638,501,77614,323,0008,763,00092,729,344