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 04:17Josu San MartinJosu San MartinScore: 20,082Success
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 03:5520,033212,521,728159,386,00022,911,00094,720,000
2Dec 24, 2025 03:5520,040208,493,718158,448,00023,916,00094,650,368
3Dec 24, 2025 03:5520,066210,209,327159,649,00022,949,00094,597,120
4Dec 24, 2025 03:5520,067204,037,405159,662,00022,951,00094,797,824
5Dec 24, 2025 04:1720,067210,343,365159,663,00022,951,00094,633,984
6Dec 24, 2025 03:5520,076211,925,856159,733,00022,961,00094,629,888
7Dec 24, 2025 04:1720,082208,988,021160,776,00021,969,00094,638,080
8Dec 24, 2025 03:5520,089208,795,719160,836,00021,977,00094,674,944
9Dec 24, 2025 03:5520,124212,052,810159,108,00024,016,00094,781,440
10Dec 24, 2025 03:5520,133206,188,395163,191,00020,023,00094,547,968
11Dec 24, 2025 04:1720,134209,722,981161,190,00022,026,00094,797,824
12Dec 24, 2025 03:5520,171212,909,158161,612,00021,947,00094,797,824