Reputation: 109
I am trying to use the Kairos API for Facial Recognition in my air app. After i send the image, kairos returns the following JSON:
{"images":[{"transaction":{"status":"failure","topLeftX":106,"topLeftY":126,"gallery_name":"Faces","eyeDistance":42,"height":98,"width":98,"face_id":1,"quality":-1.53973,"message":"No match found"}}],"uploaded_image_url":"https:\/\/kairos-east-id-images.s3.amazonaws.com\/prod\/c6d565457\/recognize\/Faces\/d2b1142f2134232349ewer8acb825c87e909f299ab1_5a234XXXXXX.jpg?X-Amz-Content-Sha246=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXXXXXXXXX-east-1%2Fs3%2XXXX_request&X-Amz-Date=2017122rrtdfg158Z&X-Amz-SignedHeaders=host&X-Amz-Expires=XXXX&X-Amz-Signature=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
I need to access the values of "topLeftX", "topLeftY" and "message" but no matter what i try it doesn't seem to work. I have been searching around for about an hour. I have tried both native JSON parser and ascorelib JSON parser.
I tried the following:
var rawData:Object = JSON.decode(e.target.data);
for ( var object:Object in rawData ){
trace(object.transaction);
}
I get this error:
Property transaction not found on String and there is no default value.
I tried with different property names but I get the same error. I have tried sever other methods as well. Such as,
rawData["transaction"][0]["topLeftX"]
It doesnt work.
Any help is greatly appreciated.
Upvotes: 1
Views: 65
Reputation: 1016
I do not have a decode function on JSON. Just a JSON.parse and a JSON.stringify however what should work for you is this.
var jsonObj = JSON.parse(yourdata); // or JSON.decode if you AS version is older
for ( var i = 0 ; i < jsonObj.images.length ; i++ ){
trace(jsonObj.images[i].transaction.status);
}
Upvotes: 2