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 21, 2026 18:11Charles CabergsCharles CabergsScore: 10,300Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 18:1310,272112,858,43175,389,00018,093,00094,793,728
2Apr 21, 2026 18:1310,272109,958,43773,376,00020,103,00094,793,728
3Apr 21, 2026 18:1310,287111,136,70874,692,00018,922,00094,797,824
4Apr 21, 2026 18:1310,289108,542,30873,710,00019,921,00094,609,408
5Apr 21, 2026 18:1310,300111,496,51469,802,00023,932,00094,789,632
6Apr 21, 2026 18:1310,320113,954,06971,933,00021,979,00094,801,920
7Apr 21, 2026 18:1310,322112,717,17369,954,00023,984,00094,797,824
8Apr 21, 2026 18:1310,357111,116,92972,193,00022,058,00094,597,120
9Apr 21, 2026 18:1310,393111,944,80472,680,00021,903,00094,801,920