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 listNov 20, 2025 18:04izotoffizotoffScore: 1,001,852Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 20, 2025 18:04997,9249,119,152,6078,575,549,000505,560,00094,621,696
2Nov 20, 2025 18:04998,1609,124,058,2498,534,724,000548,532,00094,818,304
3Nov 20, 2025 18:04999,0559,127,016,5588,569,894,000521,506,00094,715,904
4Nov 20, 2025 18:041,000,5789,138,927,7258,574,708,000530,548,00094,568,448
5Nov 20, 2025 18:041,001,8529,149,610,5478,587,323,000529,526,00094,810,112
6Nov 20, 2025 18:041,002,2459,157,388,9928,609,906,000510,520,00094,593,024
7Nov 20, 2025 18:041,006,7179,198,884,1718,585,749,000575,380,00094,625,792
8Nov 20, 2025 18:041,019,4019,313,657,2858,715,059,000561,488,00094,789,632
9Nov 20, 2025 18:041,021,2989,327,588,1708,728,368,000565,440,00094,650,368