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 13:23Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 22:37Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 22:50050,204,77736,610,0004,432,00051,650,560invalid character 's' looking for beginning of valuestderr
2Sep 4, 2026 22:50050,416,04136,890,0004,423,00051,671,040invalid character 's' looking for beginning of valuestderr
3Sep 4, 2026 22:50049,483,48336,689,0004,429,00051,707,904invalid character 's' looking for beginning of valuestderr
4Aug 19, 2026 13:282,41531,143,61613,508,0008,477,00092,721,152stderr
5Aug 19, 2026 13:282,42630,537,81713,522,0008,562,00092,786,688stderr
6Aug 19, 2026 13:282,42731,103,70713,548,0008,544,00092,762,112stderr
7Aug 19, 2026 13:282,43231,139,51513,608,0008,527,00092,815,360stderr
8Aug 19, 2026 13:282,43331,133,03613,567,0008,576,00092,749,824stderr
9Aug 19, 2026 13:282,43330,626,37113,517,0008,631,00092,688,384stderr
10Aug 19, 2026 13:282,43831,178,17813,639,0008,552,00092,778,496stderr
11Aug 19, 2026 13:282,44631,379,13713,634,0008,628,00092,786,688stderr
12Aug 19, 2026 13:282,45831,327,42513,722,0008,651,00092,733,440stderr