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 14, 2026 22:37Andrew EpsteinAndrew EpsteinScore: 3,235Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 23:083,21539,550,73920,695,0008,569,00092,778,496
2Sep 14, 2026 23:083,21839,564,50420,844,0008,441,00092,774,400
3Sep 14, 2026 23:083,22540,403,19820,843,0008,511,00092,712,960
4Sep 14, 2026 23:083,23340,452,89120,911,0008,510,00092,676,096
5Sep 14, 2026 23:083,23539,775,61720,896,0008,547,00092,749,824
6Sep 14, 2026 23:083,23540,528,10120,748,0008,695,00092,717,056
7Sep 14, 2026 23:083,24039,795,13820,921,0008,572,00092,704,768
8Sep 14, 2026 23:083,24340,554,71720,799,0008,718,00092,819,456
9Sep 14, 2026 23:083,24739,872,74920,945,0008,609,00092,725,248