I’m making a http request which returns a two dimensional array (string); and i tried to do HttpService:JSONDecode()
but it says Can't Parse JSON
, am i doing it wrong? or is there a way to decode a two dimensional array string into a table?
A code snippet would be helpful if you have one
For context, this is the raw string (i don’t know if the dots matter)
[[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
...
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]]
This is the python file which handles the request
from flask import Flask, render_template
import cv2
app = Flask(__name__, template_folder='template')
PORT = 1111
video = cv2.VideoCapture('api/BadApple.mp4')
@app.route('/')
def index():
return render_template('index.html')
@app.route('/frame/<index>', methods=['GET'])
def frame(index):
video.set(cv2.CAP_PROP_POS_FRAMES, int(index))
ret, frame = video.read()
return str(frame) # here lies the problem (its a numpy.ndarray class)
app.run(host='0.0.0.0', port=PORT, debug=False)
I fixed it just by calling frame.tolist()