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 25, 2026 22:35Charles CabergsCharles CabergsScore: 4,529Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 25, 2026 22:374,50658,512,75424,008,00017,005,00094,609,408
2Apr 25, 2026 22:374,51258,905,63624,040,00017,028,00094,797,824
3Apr 25, 2026 22:374,52256,747,05222,084,00019,073,00094,806,016
4Apr 25, 2026 22:374,52560,048,82524,108,00017,076,00094,777,344
5Apr 25, 2026 22:374,52958,129,77726,136,00015,078,00094,793,728
6Apr 25, 2026 22:374,53459,998,95524,156,00017,111,00094,609,408
7Apr 25, 2026 22:374,54359,308,34821,179,00020,170,00094,789,632
8Apr 25, 2026 22:374,57160,426,37322,782,00018,820,00094,593,024
9Apr 25, 2026 22:374,57359,977,75722,789,00018,826,00094,797,824