0

I want to update only a part of data in this json file and im struggling to do it.

the json file is as follows:

[
    {
        "IP": "Not Specified",
        "MOTD": "Not Specified",
        "Seed": "Not Specified",
        "Server_image": "Not Specified",
        "Cracked_status": "Not Specified",
        "Version": "Not Specified",
        "Software": "Not Specified",
        "Difficulty": "Not Specified"
    }
]

I want to update the IP value using python

3
  • 1
    Have you tried anything? Commented Feb 2, 2022 at 7:59
  • I have tried this but it feels too complicated Commented Feb 2, 2022 at 8:07
  • for x in dataa: for y in x: if y == 'value': var_u_writing_back = x.update({y: "value3"}) Commented Feb 2, 2022 at 8:07

2 Answers 2

2

It's very simple. You can try this solution. I hope it will work for you.

list_name[0]["IP"] = "here will be the update value"
Sign up to request clarification or add additional context in comments.

Comments

0

the easy way to convert to dict modify and convert to JSON

import json


json_t = '[{"IP":"Not Specified","MOTD":"Not Specified","Seed":"Not Specified","Server_image":"Not Specified","Cracked_status":"Not Specified","Version":"Not Specified","Software":"Not Specified","Difficulty":"Not Specified"}]'
list_t = json.loads(json_t)
# modify the dict
json_t = json.dumps(list_t)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.