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:01Dominique GarmierDominique GarmierScore: 5,495Success
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:045,45267,210,49125,803,00023,818,00094,593,024
2Apr 22, 2026 21:045,47864,790,01925,924,00023,930,00094,609,408
3Apr 22, 2026 21:045,48464,143,51026,950,00022,957,00094,695,424
4Apr 22, 2026 21:045,48972,450,76726,974,00022,978,00094,613,504
5Apr 22, 2026 21:045,49573,269,02325,006,00025,006,00094,609,408
6Apr 22, 2026 21:045,51067,935,91324,070,00026,076,00094,617,600
7Apr 22, 2026 21:045,51873,213,49326,115,00024,106,00094,617,600
8Apr 22, 2026 21:045,51873,228,33425,109,00025,109,00094,597,120
9Apr 22, 2026 21:045,52870,800,98925,154,00025,154,00094,605,312