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 listJul 30, 2026 02:26Andrew TsibinAndrew TsibinScore: 5,940Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 30, 2026 02:325,68061,789,66930,273,00021,415,00092,925,952
2Jul 30, 2026 02:325,78362,722,35230,135,00022,497,00092,938,240
3Jul 30, 2026 02:325,78462,711,20030,142,00022,493,00093,028,352
4Jul 30, 2026 02:325,80262,867,09530,149,00022,653,00092,995,584
5Jul 30, 2026 02:325,94064,137,87230,193,00023,861,00092,868,608
6Jul 30, 2026 02:325,94164,177,67330,774,00023,296,00092,901,376
7Jul 30, 2026 02:325,97564,494,71730,592,00023,785,00092,983,296
8Jul 30, 2026 02:325,99064,607,14430,283,00024,234,00092,934,144
9Jul 30, 2026 02:326,00564,700,10430,023,00024,630,00092,938,240