JSON Types → Python Types

Easy ⏱ 8 min 73% acceptance ★★★★★ 4.7
Write type_names(raw) that parses a JSON array and returns the Python type name (type(x).__name__) of each element — demonstrating the mapping: JSON null→NoneType, true→bool, 1→int, 1.5→float, string→str, array→list, object→dict.

Examples

Example 1
Input
type_names('[null, true, 1, 1.5, "x", [], {}]')
Output
['NoneType', 'bool', 'int', 'float', 'str', 'list', 'dict']
Explanation

Each JSON type lands on its Python counterpart.

Constraints

  • Input is always a JSON array.
  • Use type(x).__name__.

Topics

JSONtype mapping

Companies

OracleIBMCapgemini

Hints

Hint 1

One comprehension over the parsed list.

Hint 2

No special-casing — the mapping is automatic.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.