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:35Andrew EpsteinAndrew EpsteinScore: 2,428Success
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:412,42131,479,86813,573,0008,460,00092,774,400
2Nov 3, 2026 09:412,42331,333,11013,522,0008,532,00092,774,400
3Nov 3, 2026 09:412,42531,377,87013,603,0008,465,00092,725,248
4Nov 3, 2026 09:412,42631,414,92113,555,0008,523,00092,712,960
5Nov 3, 2026 09:412,42831,405,92313,588,0008,507,00092,770,304
6Nov 3, 2026 09:412,43031,437,19013,747,0008,371,00092,741,632
7Nov 3, 2026 09:412,43933,091,45913,583,0008,617,00092,766,208
8Nov 3, 2026 09:412,44431,482,55713,631,0008,615,00092,766,208
9Nov 3, 2026 09:412,44531,624,66113,664,0008,586,00092,807,168