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 listMay 5, 2026 06:40Victor MerckléVictor MerckléError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 13:23Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 13:43041,290,48826,161,0006,608,00066,199,552invalid character 's' looking for beginning of value
2Sep 4, 2026 13:43041,237,83726,132,0006,570,00066,289,664invalid character '<' after object key:value pair
3Sep 4, 2026 13:43041,142,80326,092,0006,681,00066,281,472invalid character 's' looking for beginning of value
4May 5, 2026 06:473,40643,790,33821,919,0009,078,00093,184,000
5May 5, 2026 06:473,41743,037,99522,194,0008,905,00093,175,808
6May 5, 2026 06:473,42147,166,66021,980,0009,157,00093,196,288
7May 5, 2026 06:473,42945,466,38322,230,0008,980,00093,192,192
8May 5, 2026 06:473,43046,491,16222,217,0009,003,00093,151,232
9May 5, 2026 06:473,43143,400,70522,356,0008,871,00093,192,192
10May 5, 2026 06:473,43245,672,38222,202,0009,033,00093,220,864
11May 5, 2026 06:473,43649,009,38522,265,0009,006,00093,155,328
12May 5, 2026 06:473,44646,425,68322,404,0008,963,00093,171,712