Question

UTILIZE A JSON method to REPLACE THE VALUE OF COURSECODE PROPERTY TO "WEB322"

UTILIZE A JSON method to REPLACE THE VALUE OF COURSECODE PROPERTY TO "WEB322"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well. Thanks

Code:

import json
#let's say you have below data for students which have coursecode as a property
studentData = """
[
{
"name": "Alex",
"coursecode": "CS201",
"semester": "1"
},
{
"name": "Craig",
"coursecode": "CS202",
"semesetr": "1"
}
]
"""
#loads the data in variable, means deserialize it
dataJson = json.loads(studentData)
#data before change
print("Data before change")
print(dataJson)

#update the property coursecode for each student
for data in dataJson:
data["coursecode"] = "WEB322"

#data after change
print("Data after change")
print(dataJson)

=========screen shot of the code for indentation=====

main.py 1 import json 2 #Lets say you have below data for students which have coursecode as a property 3 studentData = 4-

Output:

input Data before change {semester: 1, name: Alex, coursecode: CS201}, {semesetr: 1, name: Craig, course

Add a comment
Know the answer?
Add Answer to:
UTILIZE A JSON method to REPLACE THE VALUE OF COURSECODE PROPERTY TO "WEB322"
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT