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 27, 2026 20:35Victor MerckléVictor MerckléScore: 64,028Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 27, 2026 20:3763,825595,601,024562,820,00017,994,00094,830,592stderr
2Apr 27, 2026 20:3763,960602,467,563565,069,00016,972,00094,613,504stderr
3Apr 27, 2026 20:3763,976602,180,247564,209,00017,974,00094,773,248stderr
4Apr 27, 2026 20:3764,001603,442,422564,432,00017,981,00094,593,024stderr
5Apr 27, 2026 20:3764,028604,324,524562,673,00019,988,00094,842,880stderr
6Apr 27, 2026 20:3764,094599,759,879565,256,00018,008,00094,830,592stderr
7Apr 27, 2026 20:3764,099601,396,877563,328,00019,976,00094,838,784stderr
8Apr 27, 2026 20:3764,214602,839,581564,371,00019,977,00094,842,880stderr
9Apr 27, 2026 20:3764,215605,728,266566,377,00017,980,00094,838,784stderr