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 listSep 25, 2026 13:40Kevin HeaveyKevin HeaveyScore: 2,343Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 25, 2026 13:452,33729,933,92912,865,0008,408,00092,737,536
2Sep 25, 2026 13:452,33929,987,82412,869,0008,418,00092,753,920
3Sep 25, 2026 13:452,34130,020,08312,861,0008,448,00092,782,592
4Sep 25, 2026 13:452,34230,170,48112,892,0008,429,00092,737,536
5Sep 25, 2026 13:452,34330,058,83612,895,0008,431,00092,717,056
6Sep 25, 2026 13:452,34831,362,93812,895,0008,475,00092,712,960
7Sep 25, 2026 13:452,35330,167,77412,883,0008,536,00092,737,536
8Sep 25, 2026 13:452,36530,293,11013,069,0008,455,00092,700,672
9Sep 25, 2026 13:452,37730,335,42213,069,0008,568,00092,766,208