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 12:37BenBenScore: 21,640Success
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 12:4221,572213,007,609173,276,00023,036,00094,777,344
2Apr 22, 2026 12:4221,596212,455,664172,587,00023,942,00094,781,440
3Apr 22, 2026 12:4221,614213,749,862173,729,00022,964,00094,777,344
4Apr 22, 2026 12:4221,638214,405,443171,925,00024,989,00094,777,344
5Apr 22, 2026 12:4221,640219,506,924172,936,00023,991,00094,773,248
6Apr 22, 2026 12:4221,642216,137,547172,955,00023,993,00094,785,536
7Apr 22, 2026 12:4221,643216,420,905171,964,00024,994,00094,773,248
8Apr 22, 2026 12:4221,658211,897,854176,086,00021,010,00094,777,344
9Apr 22, 2026 12:4221,668219,282,160172,157,00025,022,00094,773,248