Bird
Raised Fist0

Which of the following is the correct syntax to deserialize a JSON string json_str into a Python object?

easy📝 Syntax Q12 of Q15
Python - Structured Data Files
Which of the following is the correct syntax to deserialize a JSON string json_str into a Python object?
Ajson.load(json_str)
Bjson.dumps(json_str)
Cjson.loads(json_str)
Djson.deserialize(json_str)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the function to convert JSON string to Python

    The correct function is json.loads(), which takes a JSON string and returns Python data.
  2. Step 2: Check other options for correctness

    json.dumps() serializes Python to JSON string, json.load() reads JSON from a file object, and json.deserialize() does not exist.
  3. Final Answer:

    json.loads(json_str) -> Option C
  4. Quick Check:

    loads() = JSON string to Python [OK]
Quick Trick: Use loads() to load JSON string into Python [OK]
Common Mistakes:
MISTAKES
  • Using dumps() instead of loads()
  • Confusing load() with loads()
  • Using a non-existent deserialize() function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes