This is my first time using Google Cloud Functions. And I have trouble with running the function. My code is like below.
import json
def location_sort(request):
request = json.dumps(request)
location = json.loads(request)
reverse_location = {v: k for k, v in location.items()}
x = location.keys()
harf_x = (float(max(x)) + float(min(x))) / 2
y_right = []
y_left = []
sorted_location = []
for i in location:
if float(i) < harf_x:
y_left.append(location[i])
else:
y_right.append(location[i])
y_left.sort()
y_right.sort(reverse=True)
sorted_input = y_left + y_right
for i in sorted_input:
sorted_location.append([reverse_location[i], i])
return json.dumps(sorted_location)
And i put in Trigger
{"38:127":"127.012","37.128":"127.002"}
and the error shows up saying
Error: function terminated. Recommended action: inspect logs for termination reason. Details:
Object of type LocalProxy is not JSON serializable
How can I fix my problem?