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 27, 2026 10:59Charles CabergsCharles CabergsScore: 4,380Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 27, 2026 11:014,34857,121,41218,798,00020,777,00094,793,728
2Apr 27, 2026 11:014,35258,581,99918,814,00020,794,00094,781,440
3Apr 27, 2026 11:014,36162,905,18518,851,00020,836,00094,797,824
4Apr 27, 2026 11:014,37561,077,93018,915,00020,906,00094,785,536
5Apr 27, 2026 11:014,38059,338,35917,375,00022,486,00094,793,728
6Apr 27, 2026 11:014,39156,718,90615,984,00023,976,00094,806,016
7Apr 27, 2026 11:014,39960,502,21525,024,00015,014,00094,789,632
8Apr 27, 2026 11:014,41358,397,67519,076,00021,085,00094,801,920
9Apr 27, 2026 11:014,43057,981,55919,149,00021,164,00094,806,016