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 28, 2026 00:54Charles CabergsCharles CabergsScore: 4,199Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 00:564,16859,581,71718,966,00018,966,00094,793,728
2Apr 28, 2026 00:564,16852,414,90319,967,00017,970,00094,625,792
3Apr 28, 2026 00:564,19454,526,09919,087,00019,087,00094,801,920
4Apr 28, 2026 00:564,19554,721,15518,083,00020,092,00094,613,504
5Apr 28, 2026 00:564,19953,465,42918,104,00020,115,00094,605,312
6Apr 28, 2026 00:564,20055,308,80220,120,00018,108,00094,789,632
7Apr 28, 2026 00:564,21956,746,63922,829,00015,565,00094,789,632
8Apr 28, 2026 00:564,22654,786,92323,277,00015,180,00094,617,600
9Apr 28, 2026 00:564,24557,473,39723,384,00015,250,00094,793,728