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 26, 2026 19:57TudyMTudyMScore: 28,492Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 26, 2026 19:5928,480275,039,930224,150,00035,023,00094,576,640
2Apr 26, 2026 19:5928,484275,943,749222,178,00037,029,00094,789,632
3Apr 26, 2026 19:5928,488281,971,427219,211,00040,038,00094,789,632
4Apr 26, 2026 19:5928,490278,370,410221,224,00038,038,00094,609,408
5Apr 26, 2026 19:5928,492280,301,288224,244,00035,038,00094,785,536
6Apr 26, 2026 19:5928,502284,176,392222,459,00036,910,00094,781,440
7Apr 26, 2026 19:5928,512276,008,515215,558,00043,909,00094,781,440
8Apr 26, 2026 19:5928,539279,749,726217,753,00041,952,00094,797,824
9Apr 26, 2026 19:5928,777278,811,188218,894,00042,979,00094,793,728