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 listApr 23, 2026 22:20olliecrowolliecrowScore: 6,011Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2026 22:245,91569,153,53435,889,00017,944,00094,584,832
2Apr 23, 2026 22:245,93862,364,30838,744,00015,293,00094,633,984
3Apr 23, 2026 22:245,94862,283,37740,100,00014,035,00094,654,464
4Apr 23, 2026 22:245,95862,812,73439,163,00015,063,00094,654,464
5Apr 23, 2026 22:246,01163,065,87834,812,00019,892,00094,654,464
6Apr 23, 2026 22:246,05462,520,42640,072,00015,027,00094,633,984
7Apr 23, 2026 22:246,05462,433,46133,058,00022,039,00094,740,480
8Apr 23, 2026 22:246,07462,680,49242,213,00013,065,00094,654,464
9Apr 23, 2026 22:246,09662,978,70039,340,00016,139,00094,650,368