【问题标题】:how the web-service can display the contents of object of type array [duplicate]Web服务如何显示数组类型对象的内容[重复]
【发布时间】:2021-04-29 05:18:15
【问题描述】:

在下面发布的代码中,featuresArray 是一个特征数组。我希望下面发布的 web 服务返回代码中所述的“featuresArray”。当运行我收到的应用程序时

internal server error

但是,例如,当我返回时

feature[0] or specify the index

网络服务显示该值。

那么我怎样才能让网络服务返回并显示对象freaturesArray

python 代码

@app.route("/geodata/<string:polygonCoordinates>", methods=['GET'] )
def geodata(polygonCoordinates):
...
...
url = url.replace(" ","%20")
backendResponseAsJSON = readResponseAsJSONForURL(url)
geojsonObjectAsJSON = loadDataAsJSON(backendResponseAsJSON['geojson'][0])
featuresArray = geojsonObjectAsJSON['features']
for feature in featuresArray:
    pass#print (feature)

#baseURL = config['EndPoint']['https'] + config['EndPoint']['url'] + config['EndPoint']['api_key'] + config['EndPoint']['start'] + polygonCoordinates + "," + polygonCoordinates + config['EndPoint']['end'] + polygonCoordinates + "," + polygonCoordinates
#print("baseURL: %s"%(baseURL))
return featuresArray

【问题讨论】:

    标签: python json web-services flask flask-restful


    【解决方案1】:

    数组或列表必须包含在里面 字符串() 只需执行以下操作:

     return str(featureArray)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 2011-12-16
      • 1970-01-01
      • 2017-07-16
      • 2014-09-11
      • 2011-04-10
      相关资源
      最近更新 更多