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 listJun 11, 2026 16:08Victor MerckléVictor MerckléScore: 2,741Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 16:132,73233,970,22916,084,0008,780,00092,688,384
2Jun 11, 2026 16:132,73433,865,69016,145,0008,736,00092,651,520
3Jun 11, 2026 16:132,73433,934,18016,160,0008,728,00092,737,536
4Jun 11, 2026 16:132,73933,956,53216,132,0008,797,00092,700,672
5Jun 11, 2026 16:132,74133,997,80516,162,0008,790,00092,725,248
6Jun 11, 2026 16:132,74334,009,35416,166,0008,804,00092,733,440
7Jun 11, 2026 16:132,75134,046,19916,153,0008,885,00092,770,304
8Jun 11, 2026 16:132,75634,056,57716,213,0008,872,00092,725,248
9Jun 11, 2026 16:132,76034,139,86816,225,0008,897,00092,762,112