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 23, 2026 08:59Charles CabergsCharles CabergsScore: 5,003Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2026 09:014,95367,274,93730,051,00015,025,00094,801,920
2Apr 23, 2026 09:014,97966,625,09329,200,00016,110,00094,609,408
3Apr 23, 2026 09:014,99060,829,70133,300,00012,109,00094,617,600
4Apr 23, 2026 09:014,99764,425,43331,329,00014,148,00094,785,536
5Apr 23, 2026 09:015,00360,850,22231,369,00014,166,00094,597,120
6Apr 23, 2026 09:015,00565,745,68929,357,00016,197,00094,793,728
7Apr 23, 2026 09:015,00868,612,46326,333,00019,243,00094,797,824
8Apr 23, 2026 09:015,01467,925,36129,762,00015,873,00094,789,632
9Apr 23, 2026 09:015,01765,287,03927,793,00017,867,00094,785,536