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 listJul 1, 2026 22:37A_ShamanA_ShamanScore: 34,872Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 22:4334,777326,050,269258,400,00058,078,000169,893,888
2Jul 1, 2026 22:4334,808326,269,248258,544,00058,211,000171,991,040
3Jul 1, 2026 22:4334,812326,332,167258,314,00058,484,000171,991,040
4Jul 1, 2026 22:4334,827326,359,564258,513,00058,421,000171,991,040
5Jul 1, 2026 22:4334,872326,889,978258,546,00058,790,000171,991,040
6Jul 1, 2026 22:4335,012328,482,907259,413,00059,200,000169,893,888
7Jul 1, 2026 22:4335,058328,909,125259,162,00059,868,000169,893,888
8Jul 1, 2026 22:4335,194329,819,003257,869,00062,403,000169,893,888
9Jul 1, 2026 22:4335,544333,469,683259,350,00064,108,000169,893,888