I'm trying to read a json file from a different folder however the values in it are of an older version of the file. However different jsons in the same folder are read correctly. And if i copy apply.json to my pwd it is working correctly in that case. For example -
'''In the json:
AmountMax : 0
When read in python:
AmountMax : 90'''
with open("../frontend/src/components/Presets/apply.json") as infile:
settings_data = json.load(infile)
print(settings_data)
I'm completely clueless as to how or why this is happening, any suggestion or help would be great thanks. I've tried making sure the paths are correct and even recreated the file.
Edit: Here are the outputs as follows
apply.json -
{
"Active": "Preset 0",
"reqAmountMin": 0,
"reqAmountMax": 0
}
Python Output reading apply.json from orignal folder -
{'reqAmountMin': 0, 'reqAmountMax': 90}
Python Output reading apply.json copied to pwd -
{'Active': 'Preset 0', 'reqAmountMin': 0, 'reqAmountMax': 0}
Check Working Directory
If the script is not in the same directory as the JSON file( your case), you might need to adjust the relative path accordingly.
Replace "/absolute/path/apply.json" with the actual absolute path to the file.