JSON:
{
"map": {
"id": "2018-SampleSimulation",
"steps": 1000,
"map": "Porto Alegre",
"minLon": 2.26,
"maxLon": 2.41,
"minLat": 48.82,
"maxLat": 48.9,
"centerLat": 48.8424,
"centerLon": 2.3209,
"proximity": 5,
"randomSeed": 2018,
"gotoCost": 2,
"rechargeRate": 2
},
"agents": {
"car": 2,
"drone": 4,
"boat": 1
},
"roles": {
"drone": {
"speed": 7,
"capacity_physical": 10,
"capacity_virtual": 10,
"battery": 20,
"abilities": [
[
"photo",
7.2,
2.3
],
[
"victim",
0
],
[
"water",
0
]
],
"percieve": 5,
"kind": "air"
},
"car": {
"speed": 7,
"capacity_physical": 10,
"capacity_virtual": 10,
"battery": 20,
"abilities": [
[
"photo",
7.2,
2.3
],
[
"victim",
5
],
[
"water",
0
]
],
"percieve": 5,
"kind": "earth"
},
"boat": {
"speed": 7,
"capacity_physical": 10,
"capacity_virtual": 10,
"battery": 20,
"abilities": [
[
"photo",
7.2,
2.3
],
[
"victim",
5
],
[
"water",
10
]
],
"percieve": 5,
"kind": "water"
}
},
"generate": {
"quadSize": 2,
"floodProbability": 5,
"flood": {
"minPeriod": 40,
"maxPeriod": 80,
"circle": {
"minRadius": 34,
"maxRadius": 90
},
"rectangle": {
"minHeight": 30,
"maxHeight": 70,
"minLength": 20,
"maxLength": 60
}
},
"photo": {
"size": 3,
"minAmount": 5,
"maxAmount": 10,
"victimProbability": 60
},
"victim": {
"minSize": 5,
"maxSize": 10,
"minAmount": 5,
"maxAmount": 10,
"minLifetime": 30,
"maxLifetime": 40
},
"waterSample": {
"size": 4,
"minAmount": 5,
"maxAmount": 10
}
}
}
Python:
import json
from pprint import pprint
with open('config.json') as f:
data = json.load(f)
idMatch = data["map"]["id"]
steps = data["map"]["steps"]
mapMatch = data["map"]["map"]
minLon = data["map"]["minLon"]
maxLon = data["map"]["maxLon"]
minLat = data["map"]["minLat"]
maxLat = data["map"]["maxLat"]
centerLat = data["map"]["centerLat"]
centerLon = data["map"]["centerLon"]
proximity = data["map"]["proximity"]
randomSeed = data["map"]["randomSeed"]
goToCost = data["map"]["gotoCost"]
rechargeRate = data["map"]["rechargeRate"]
numCar = data["agents"]["car"]
numDrone = data["agents"]["drone"]
numBoat = data["agents"]["boat"]
speedDrone = data["roles"]["drone"]["speed"]
capPhysicalDrone = data["roles"]["drone"]["capacity_physical"]
capVirtualDrone = data["roles"]["drone"]["capacity_virtual"]
batteryDrone = data["roles"]["drone"]["battery"]
photoAbDrone = data["roles"]["drone"]["abilities"][0]
victimAbDrone = data["roles"]["drone"]["abilities"][1]
waterAbDrone = data["roles"]["drone"]["abilities"][2]
percieveDrone = data["roles"]["drone"]["percieve"]
kindDrone = data["roles"]["drone"]["kind"]
speedCar = data["roles"]["car"]["speed"]
capPhysicalCar = data["roles"]["car"]["capacity_physical"]
capVirtualCar = data["roles"]["car"]["capacity_virtual"]
batteryCar = data["roles"]["car"]["battery"]
photoAbCar = data["roles"]["car"]["abilities"][0]
victimAbCar = data["roles"]["car"]["abilities"][1]
waterAbCar = data["roles"]["car"]["abilities"][2]
percieveCar = data["roles"]["car"]["percieve"]
kindCar = data["roles"]["car"]["kind"]
speedBoat = data["roles"]["boat"]["speed"]
capPhysicalBoat = data["roles"]["boat"]["capacity_physical"]
capVirtualBoat = data["roles"]["boat"]["capacity_virtual"]
batteryBoat = data["roles"]["boat"]["battery"]
photoAbBoat = data["roles"]["boat"]["abilities"][0]
victimAbBoat = data["roles"]["boat"]["abilities"][1]
waterAbBoat = data["roles"]["boat"]["abilities"][2]
percieveBoat = data["roles"]["boat"]["percieve"]
kindBoat = data["roles"]["boat"]["kind"]
quadSize = data["generate"]["quadSize"]
floodProbability = data["generate"]["floodProbability"]
floodMinPeriod = data["generate"]["flood"]["minPeriod"]
floodMaxPeriod = data["generate"]["flood"]["maxPeriod"]
circleMinRad = data["generate"]["flood"]["circle"]["minRadius"]
circleMaxRad = data["generate"]["flood"]["circle"]["maxRadius"]
rectMinHeight = data["generate"]["flood"]["rectangle"]["minHeight"]
rectMaxHeight = data["generate"]["flood"]["rectangle"]["minHeight"]
rectMinLength = data["generate"]["flood"]["rectangle"]["minLength"]
rectMaxLength = data["generate"]["flood"]["rectangle"]["maxLength"]
photoSize = data["generate"]["photo"]["size"]
photoMinAmount = data["generate"]["photo"]["minAmount"]
photoMaxAmount = data["generate"]["photo"]["maxAmount"]
photoVictimProb = data["generate"]["photo"]["victimProbability"]
victimMinSize = data["generate"]["victim"]["minSize"]
victimMaxSize = data["generate"]["victim"]["maxSize"]
victimMinAmount = data["generate"]["victim"]["minAmount"]
victimMaxAmount = data["generate"]["victim"]["maxAmount"]
victimMinLifetime = data["generate"]["victim"]["minLifetime"]
victimMaxLifetime = data["generate"]["victim"]["maxLifetime"]
waterSampleSize = data["generate"]["waterSample"]["size"]
waterSampleMin = data["generate"]["waterSample"]["minAmount"]
WaterSampleMax = data["generate"]["waterSample"]["maxAmount"]
print(victimMinLifetime)