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 listNov 3, 2026 05:22Andrew EpsteinAndrew EpsteinScore: 2,547Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:402,50933,591,36014,062,0008,771,00092,770,304
2Nov 3, 2026 05:402,51033,700,78614,040,0008,808,00092,741,632
3Nov 3, 2026 05:402,51933,847,61314,158,0008,765,00092,725,248
4Nov 3, 2026 05:402,53034,501,52414,205,0008,824,00092,737,536
5Nov 3, 2026 05:402,54734,075,73114,366,0008,816,00092,733,440
6Nov 3, 2026 05:402,54834,092,54414,325,0008,867,00092,811,264
7Nov 3, 2026 05:402,56034,149,88414,366,0008,930,00092,708,864
8Nov 3, 2026 05:402,56034,690,66714,336,0008,966,00092,725,248
9Nov 3, 2026 05:402,56634,221,36614,459,0008,894,00092,741,632