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 11, 2026 18:38Victor MerckléVictor MerckléScore: 2,713Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:432,70233,634,31015,841,0008,755,00092,684,288
2Jun 11, 2026 18:432,70733,766,52115,864,0008,778,00092,745,728
3Jun 11, 2026 18:432,70733,695,38215,896,0008,746,00092,725,248
4Jun 11, 2026 18:432,70933,707,26315,926,0008,734,00092,700,672
5Jun 11, 2026 18:432,71333,689,27715,880,0008,814,00092,774,400
6Jun 11, 2026 18:432,72033,824,98215,923,0008,830,00092,717,056
7Jun 11, 2026 18:432,72533,834,70216,002,0008,804,00092,745,728
8Jun 11, 2026 18:432,73133,891,10215,974,0008,883,00092,700,672
9Jun 11, 2026 18:432,73533,930,15116,009,0008,886,00092,737,536