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 09:16olliecrowolliecrowScore: 5,147Success
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 09:185,12553,735,37420,838,00025,800,00094,601,216
2Apr 22, 2026 09:185,14062,591,22832,846,00013,934,00094,748,672
3Apr 22, 2026 09:185,14353,664,46428,878,00017,924,00094,605,312
4Apr 22, 2026 09:185,14464,820,30623,905,00022,909,00094,756,864
5Apr 22, 2026 09:185,14753,601,30120,928,00025,911,00094,756,864
6Apr 22, 2026 09:185,18253,946,73125,088,00022,077,00094,601,216
7Apr 22, 2026 09:185,25053,527,44531,850,00015,925,00094,605,312
8Apr 22, 2026 09:185,25053,558,45731,855,00015,927,00094,601,216
9Apr 22, 2026 09:185,25453,851,57522,912,00024,905,00094,593,024