Ask Question
28 January, 05:44

Write a function named "read_json" that takes a JSON formatted string as a parameter and return the data represented by the input in the appropriate types for this language. For example, if the input string represents a JSON object you should return a key-value store containing the same data?

+2
Answers (1)
  1. 28 January, 06:01
    0
    Following are the program in the Python Programming Language.

    import json #import package

    #define function

    def read_json (info):

    return json. loads (info) #load data in variable

    #call and print the function

    print (read_json ('[{'A': 10}, {'Y': 16}, {'U': 28}]'))

    Output:

    [{'A': 10}, {'Y': 16}, {'U': 28}]

    Explanation:

    following are the description of the code

    Define function "read_json () " and pass an argument "info" inside it. Return the data inside from the "load () " function. Call the function i. e "read_json" and passing the value to that function. Print function print the data which is inside the "read_json" function.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a function named "read_json" that takes a JSON formatted string as a parameter and return the data represented by the input in the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers