我在 Sails 中构建了一个简单的 REST 应用程序,我想将正确的数据保存在 type 的模型属性中array
。
发帖路线
http://localhost:1337/locations/create?name=savassibeer&locations={latitude:23789472398.2344,longitude:2734637892.56756756}&locations={latitude:22.2344,longitude:2562.56756756,date:2014-02-15T11:00:00}
结果
{
name: "savassibeer",
locations: [
"{latitude:23789472398.2344,longitude:2734637892.56756756}",
"{latitude:22.2344,longitude:2562.56756756,date:2014-02-15T21:49:23.084Z}"
],
createdAt: "2014-02-15T21:49:23.084Z",
updatedAt: "2014-02-15T21:49:23.084Z",
id: "52ffe0e345d19ec72b4fac77"
}
如何将字符串转换locations
为有效的 JSON 对象并保存?