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 06:46Andrew EpsteinAndrew EpsteinScore: 2,470Success
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 06:522,45131,626,96813,748,0008,563,00092,745,728
2Nov 3, 2026 06:522,45331,597,03713,790,0008,538,00092,733,440
3Nov 3, 2026 06:522,45832,133,29813,818,0008,554,00092,717,056
4Nov 3, 2026 06:522,46831,771,33913,876,0008,590,00092,745,728
5Nov 3, 2026 06:522,47032,246,36813,875,0008,603,00092,745,728
6Nov 3, 2026 06:522,47032,299,26613,929,0008,553,00092,696,576
7Nov 3, 2026 06:522,47831,881,09413,866,0008,685,00092,737,536
8Nov 3, 2026 06:522,48338,279,17713,892,0008,708,00092,749,824
9Nov 3, 2026 06:522,49132,462,39313,982,0008,693,00092,778,496