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 30, 2026 13:07Charles CabergsCharles CabergsScore: 4,021Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2026 13:093,99354,525,92919,178,00017,160,00094,801,920
2Apr 30, 2026 13:093,99453,895,04620,195,00016,156,00094,797,824
3Apr 30, 2026 13:093,99651,645,69719,193,00017,172,00094,797,824
4Apr 30, 2026 13:094,00656,180,23518,228,00018,228,00094,793,728
5Apr 30, 2026 13:094,02152,356,57220,329,00016,263,00094,801,920
6Apr 30, 2026 13:094,03254,890,78017,853,00018,845,00094,789,632
7Apr 30, 2026 13:094,03854,358,88820,858,00015,892,00094,797,824
8Apr 30, 2026 13:094,04056,461,05417,361,00019,404,00094,793,728
9Apr 30, 2026 13:094,05853,380,34118,964,00017,966,00094,801,920