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 10, 2026 00:16Victor MerckléVictor MerckléScore: 3,072Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 00:213,06136,876,11618,405,0009,454,00092,745,728
2Jun 10, 2026 00:213,06236,874,23518,342,0009,525,00092,770,304
3Jun 10, 2026 00:213,06736,889,05618,365,0009,545,00092,741,632
4Jun 10, 2026 00:213,06736,870,50718,399,0009,513,00092,786,688
5Jun 10, 2026 00:213,07237,019,05618,396,0009,561,00092,753,920
6Jun 10, 2026 00:213,08737,114,44418,443,0009,657,00092,811,264
7Jun 10, 2026 00:213,08837,200,40518,458,0009,645,00092,749,824
8Jun 10, 2026 00:213,09237,072,85518,506,0009,633,00092,737,536
9Jun 10, 2026 00:213,09837,272,80218,565,0009,635,00092,700,672