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 22, 2026 20:55Dominique GarmierDominique GarmierScore: 7,737Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 20:587,69592,756,52631,012,00039,015,00094,760,960
2Apr 22, 2026 20:587,70891,390,01429,060,00041,085,00094,756,864
3Apr 22, 2026 20:587,71187,712,96724,061,00046,118,00094,756,864
4Apr 22, 2026 20:587,71485,651,51927,077,00043,123,00094,765,056
5Apr 22, 2026 20:587,73787,814,35128,166,00042,249,00094,777,344
6Apr 22, 2026 20:587,76484,506,69522,890,00047,771,00094,756,864
7Apr 22, 2026 20:587,78485,065,56628,934,00041,905,00094,781,440
8Apr 22, 2026 20:587,83489,036,77126,109,00045,189,00094,765,056
9Apr 22, 2026 20:587,84085,399,17426,126,00045,219,00094,760,960