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 04:26Andrew EpsteinAndrew EpsteinScore: 2,955Success
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 04:472,94838,146,85118,332,0008,496,00092,749,824
2Nov 3, 2026 04:472,94938,206,49718,324,0008,517,00092,770,304
3Nov 3, 2026 04:472,95137,752,31518,306,0008,555,00092,725,248
4Nov 3, 2026 04:472,95538,334,37218,324,0008,568,00092,766,208
5Nov 3, 2026 04:472,95537,998,75018,360,0008,535,00092,741,632
6Nov 3, 2026 04:472,95637,681,95818,311,0008,593,00092,798,976
7Nov 3, 2026 04:472,95837,840,47418,358,0008,561,00092,749,824
8Nov 3, 2026 04:472,96038,324,53618,388,0008,553,00092,782,592
9Nov 3, 2026 04:472,97338,584,95218,436,0008,627,00092,737,536