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 listSep 14, 2026 01:59Andrew EpsteinAndrew EpsteinScore: 4,918Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 02:054,78253,853,86726,459,00017,058,00094,392,320
2Sep 14, 2026 02:054,79754,007,30826,679,00016,979,00094,392,320
3Sep 14, 2026 02:054,83454,326,54926,821,00017,170,00094,392,320
4Sep 14, 2026 02:054,87654,938,47427,445,00016,934,00094,392,320
5Sep 14, 2026 02:054,91855,790,96127,639,00017,117,00094,392,320
6Sep 14, 2026 02:054,97955,559,82928,490,00016,824,00094,392,320
7Sep 14, 2026 02:054,98655,689,65228,486,00016,892,00094,392,320
8Sep 14, 2026 02:055,09357,490,54829,056,00017,291,00094,392,320
9Sep 14, 2026 02:055,22857,835,69530,669,00016,908,00094,392,320