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 09:35Andrew EpsteinAndrew EpsteinScore: 2,474Success
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 09:472,44931,587,39313,818,0008,471,00092,717,056
2Nov 3, 2026 09:472,45231,656,55413,837,0008,477,00092,745,728
3Nov 3, 2026 09:472,45331,604,85213,819,0008,509,00092,745,728
4Nov 3, 2026 09:472,47031,754,01213,952,0008,531,00092,741,632
5Nov 3, 2026 09:472,47431,822,95613,935,0008,584,00092,692,480
6Nov 3, 2026 09:472,47631,798,54813,930,0008,609,00092,741,632
7Nov 3, 2026 09:472,47831,848,58613,953,0008,597,00092,700,672
8Nov 3, 2026 09:472,48131,959,01313,866,0008,716,00092,749,824
9Nov 3, 2026 09:472,49632,120,46314,042,0008,672,00092,712,960