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 21:15Dominique GarmierDominique GarmierScore: 5,422Success
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 21:195,39966,037,80725,067,00024,064,00092,516,352
2Apr 22, 2026 21:195,40972,451,53525,115,00024,110,00092,495,872
3Apr 22, 2026 21:195,41970,405,11426,170,00023,150,00092,495,872
4Apr 22, 2026 21:195,41966,698,01925,164,00024,157,00092,516,352
5Apr 22, 2026 21:195,42268,495,96227,189,00022,154,00092,508,160
6Apr 22, 2026 21:195,43066,755,99025,699,00023,723,00092,495,872
7Apr 22, 2026 21:195,43365,598,57825,225,00024,216,00092,499,968
8Apr 22, 2026 21:195,43866,727,00525,250,00024,240,00092,512,256
9Apr 22, 2026 21:195,45469,846,09924,818,00024,818,00092,692,480