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 26, 2026 18:29Charles CabergsCharles CabergsScore: 4,320Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 26, 2026 18:324,30459,851,51622,097,00017,075,00094,781,440
2Apr 26, 2026 18:324,31057,519,62919,112,00020,118,00094,793,728
3Apr 26, 2026 18:324,31859,807,04219,143,00020,151,00094,613,504
4Apr 26, 2026 18:324,31954,474,92322,175,00017,135,00094,797,824
5Apr 26, 2026 18:324,32054,476,09518,145,00021,169,00094,609,408
6Apr 26, 2026 18:324,32955,396,24423,237,00016,165,00094,793,728
7Apr 26, 2026 18:324,33454,411,24825,287,00014,160,00094,806,016
8Apr 26, 2026 18:324,34358,377,58021,282,00018,242,00094,789,632
9Apr 26, 2026 18:324,34459,952,38518,777,00020,754,00094,801,920