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 listJun 21, 2026 00:28Victor MerckléVictor MerckléScore: 4,299Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 21, 2026 00:344,26648,175,13328,837,0009,990,00092,798,976
2Jun 21, 2026 00:344,27448,184,78728,596,00010,305,00092,770,304
3Jun 21, 2026 00:344,29048,241,18228,741,00010,303,00092,737,536
4Jun 21, 2026 00:344,29148,343,55029,521,0009,534,00092,794,880
5Jun 21, 2026 00:344,29948,360,44828,723,00010,401,00092,762,112
6Jun 21, 2026 00:344,30448,357,00728,839,00010,334,00092,790,784
7Jun 21, 2026 00:344,30548,356,09129,640,0009,538,00092,762,112
8Jun 21, 2026 00:344,31748,494,70528,845,00010,440,00092,753,920
9Jun 21, 2026 00:344,32648,545,93828,814,00010,559,00092,852,224