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 21, 2026 21:07BenBenScore: 29,786Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 21:0929,724288,219,815224,579,00045,914,00094,593,024
2Apr 21, 2026 21:0929,734290,797,700218,666,00051,920,00094,613,504
3Apr 21, 2026 21:0929,756291,167,575224,823,00045,963,00094,834,688
4Apr 21, 2026 21:0929,779286,624,485230,991,00039,998,00094,638,080
5Apr 21, 2026 21:0929,786289,594,994225,219,00045,841,00094,621,696
6Apr 21, 2026 21:0929,822288,853,151224,495,00046,894,00094,617,600
7Apr 21, 2026 21:0929,875289,586,781224,893,00046,977,00094,613,504
8Apr 21, 2026 21:0929,940292,532,529227,549,00044,911,00094,597,120
9Apr 21, 2026 21:0929,958291,609,431227,686,00044,938,00094,613,504