put req screenshot Hi I am currently trying to parse the following post request in a python
-------------------------------28947758029299
Content-Disposition: form-data; name="eventData"; filename="eventData.txt"
Content-Type: application/json; charset=utf-8
{
"Rule" : "sendSpots",
"Alert" : [
{
"Event" : {
"Version" : "1",
"EventUUID" : "fe1817b9-8557-4784-b64a-617c50fe27b8",
"Type" : "Vision",
"Subtype" : "Alarm",
"SensorUUID" : "!id:9298e8e1-feb0-48e3-9c44-11ee42672ac9!",
"Origin" : "DVS-BOX-PC",
"InstanceType" : "ParkingSpaceAnalyzer",
"InstanceName" : "ParkingSpotAnalyser",
"SubName" : "P01",
"FrameTime" : "2018-04-19T09:59:41.0970000Z",
"Parameters" : [
{
"Name" : "DURATION",
"Type" : "int",
"Value" : "3669869"
},
{
"Name" : "STREAM_RESOLUTION",
"Type" : "string",
"Value" : "1280,720"
},
{
"Name" : "GENERIC_XML",
"Type" : "string",
"Value" : "<EventData><ParkingState type=\"string\">occupied</ParkingState><ParkingDurationExceeded type=\"int\">1</ParkingDurationExceeded></EventData>"
},
{
"Name" : "REGION",
"Type" : "string",
"Value" : "638,613 694,377 792,373 695,614"
}
]
}
}
]
}
-------------------------------28947758029299--
I wish to extract Event as a dictionary such that I can access the version value, the Subname value and SensorUUId. To attempt to extract this info I have used the code
data = request.form
body = data['-------------------------------28947758029299\nContent-Disposition: form-data; name']
However this returns the below as type unicode:
"eventData"; filename="eventData.txt"
Content-Type: application/json; charset=utf-8
{
"Rule" : "sendSpots",
"Alert" : [
{
"Event" : {
"Version" : "1",
"EventUUID" : "fe1817b9-8557-4784-b64a-617c50fe27b8",
"Type" : "Vision",
"Subtype" : "Alarm",
"SensorUUID" : "!id:9298e8e1-feb0-48e3-9c44-11ee42672ac9!",
"Origin" : "DVS-BOX-PC",
"InstanceType" : "ParkingSpaceAnalyzer",
"InstanceName" : "ParkingSpotAnalyser",
"SubName" : "P01",
"FrameTime" : "2018-04-19T09:59:41.0970000Z",
"Parameters" : [
{
"Name" : "DURATION",
"Type" : "int",
"Value" : "3669869"
},
{
"Name" : "STREAM_RESOLUTION",
"Type" : "string",
"Value" : "1280,720"
},
{
"Name" : "GENERIC_XML",
"Type" : "string",
"Value" : "<EventData><ParkingState type=\"string\">occupied</ParkingState><ParkingDurationExceeded type=\"int\">1</ParkingDurationExceeded></EventData>"
},
{
"Name" : "REGION",
"Type" : "string",
"Value" : "638,613 694,377 792,373 695,614"
}
]
}
}
]
}
-------------------------------28947758029299--
I do not know how to go any further, cheers.