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:47Andrew EpsteinAndrew EpsteinScore: 2,545Success
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:532,52435,195,40714,194,0008,783,00092,737,536
2Nov 3, 2026 05:532,53434,004,37614,224,0008,844,00092,717,056
3Nov 3, 2026 05:532,53533,998,91614,454,0008,619,00092,717,056
4Nov 3, 2026 05:532,54234,524,34514,307,0008,832,00092,733,440
5Nov 3, 2026 05:532,54534,689,25714,338,0008,829,00092,725,248
6Nov 3, 2026 05:532,54534,546,59414,345,0008,820,00092,749,824
7Nov 3, 2026 05:532,54935,258,03714,316,0008,888,00092,782,592
8Nov 3, 2026 05:532,57034,712,95514,449,0008,940,00092,700,672
9Nov 3, 2026 05:532,57134,733,94214,429,0008,970,00092,786,688