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 listApr 24, 2026 02:24olliecrowolliecrowScore: 5,315Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 24, 2026 02:265,29266,299,85733,110,00015,050,00094,801,920
2Apr 24, 2026 02:265,29467,137,54230,110,00018,066,00094,810,112
3Apr 24, 2026 02:265,30269,039,10829,151,00019,099,00094,617,600
4Apr 24, 2026 02:265,30567,789,55130,176,00018,105,00094,801,920
5Apr 24, 2026 02:265,31562,286,15831,238,00017,130,00094,806,016
6Apr 24, 2026 02:265,31762,549,19730,246,00018,147,00094,797,824
7Apr 24, 2026 02:265,32467,965,37729,275,00019,180,00094,810,112
8Apr 24, 2026 02:265,33065,271,53430,690,00017,820,00094,613,504
9Apr 24, 2026 02:265,33265,082,66328,719,00019,806,00094,605,312