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 listAug 19, 2026 06:45Victor MerckléVictor MerckléScore: 4,999Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 06:514,95853,210,59417,114,00028,010,00092,696,576stderr
2Aug 19, 2026 06:514,97353,602,43017,102,00028,157,00092,758,016stderr
3Aug 19, 2026 06:514,98754,361,09017,145,00028,241,00092,745,728stderr
4Aug 19, 2026 06:514,99054,404,60317,164,00028,254,00092,749,824stderr
5Aug 19, 2026 06:514,99954,507,38317,226,00028,269,00092,704,768stderr
6Aug 19, 2026 06:515,00153,851,09117,169,00028,343,00092,753,920stderr
7Aug 19, 2026 06:515,00753,978,43717,269,00028,303,00092,753,920stderr
8Aug 19, 2026 06:515,00854,070,62817,246,00028,329,00092,741,632stderr
9Aug 19, 2026 06:515,00954,530,58317,220,00028,362,00092,741,632stderr