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 listApr 22, 2026 21:05Dominique GarmierDominique GarmierScore: 5,522Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 21:075,49863,574,69927,022,00023,018,00094,605,312
2Apr 22, 2026 21:075,51667,604,63127,109,00023,092,00094,699,520
3Apr 22, 2026 21:075,51765,553,14625,105,00025,105,00094,621,696
4Apr 22, 2026 21:075,51964,715,63024,111,00026,120,00094,588,928
5Apr 22, 2026 21:075,52266,876,10425,127,00025,127,00094,613,504
6Apr 22, 2026 21:075,52472,302,26327,150,00023,127,00094,625,792
7Apr 22, 2026 21:075,53065,672,87124,157,00026,170,00094,613,504
8Apr 22, 2026 21:075,54668,136,24927,255,00023,217,00094,593,024
9Apr 22, 2026 21:075,56572,674,66627,805,00022,840,00094,588,928