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 listSep 17, 2026 15:25Victor MerckléVictor MerckléScore: 208,026Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 15:39207,6481,900,211,6371,843,366,00046,238,00094,425,088stderr
2Sep 17, 2026 15:39207,6851,900,182,0111,843,355,00046,585,00094,425,088stderr
3Sep 17, 2026 15:39207,6921,900,102,5431,843,372,00046,632,00094,420,992stderr
4Sep 17, 2026 15:39207,6951,900,131,0491,843,453,00046,580,00094,486,528stderr
5Sep 17, 2026 15:39208,0261,903,482,8321,847,577,00045,462,00094,425,088stderr
6Sep 17, 2026 15:39208,3511,906,184,0021,849,425,00046,575,00094,425,088stderr
7Sep 17, 2026 15:39208,4421,907,053,7541,850,284,00046,541,00094,425,088stderr
8Sep 17, 2026 15:39208,8501,911,029,9471,850,194,00050,348,00094,425,088stderr
9Sep 17, 2026 15:39209,9621,921,865,3871,863,551,00047,110,00094,425,088stderr