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éScore: 3,430Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 06:473,40643,790,33821,919,0009,078,00093,184,000
2May 5, 2026 06:473,41743,037,99522,194,0008,905,00093,175,808
3May 5, 2026 06:473,42147,166,66021,980,0009,157,00093,196,288
4May 5, 2026 06:473,42945,466,38322,230,0008,980,00093,192,192
5May 5, 2026 06:473,43046,491,16222,217,0009,003,00093,151,232
6May 5, 2026 06:473,43143,400,70522,356,0008,871,00093,192,192
7May 5, 2026 06:473,43245,672,38222,202,0009,033,00093,220,864
8May 5, 2026 06:473,43649,009,38522,265,0009,006,00093,155,328
9May 5, 2026 06:473,44646,425,68322,404,0008,963,00093,171,712