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 listDec 24, 2025 01:24Josu San MartinJosu San MartinScore: 28,186Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 24, 2025 01:2127,844285,694,559230,434,00022,943,00094,715,904
2Dec 24, 2025 01:2127,852282,200,864232,498,00020,954,00094,797,824
3Dec 24, 2025 01:2127,909278,334,111232,976,00020,997,00094,801,920
4Dec 24, 2025 01:2128,021280,491,016232,989,00021,998,00094,707,712
5Dec 24, 2025 01:2128,037275,267,641231,124,00024,012,00094,765,056
6Dec 24, 2025 01:2428,118282,800,028231,889,00023,988,00094,801,920
7Dec 24, 2025 01:2128,186283,193,280231,543,00024,950,00094,699,520
8Dec 24, 2025 01:2428,237281,797,516234,960,00021,996,00094,797,824
9Dec 24, 2025 01:2128,318282,304,039232,721,00024,970,00094,801,920
10Dec 24, 2025 01:2428,575286,059,289232,026,00028,003,00094,797,824
11Dec 24, 2025 01:2128,677289,832,055232,968,00027,996,00094,801,920
12Dec 24, 2025 01:2128,694287,948,583234,104,00027,012,00094,629,888