客户端传来的参数与服务器中的参数不一样。

问题描述 投票:0回答:0

我传入的参数是这个向量。

[{:description "Regent Thai, Church Street, San Francisco, CA, USA", :id "254f506a2fddd4fecbbbd750e0e91d7871218065", :matched_substrings [{:length 3, :offset 0}], :place_id "ChIJi3wlq2l-j4ARq5Rg0kuektg", :reference "ChIJi3wlq2l-j4ARq5Rg0kuektg", :structured_formatting {:main_text "Regent Thai", :main_text_matched_substrings [{:length 3, :offset 0}], :secondary_text "Church Street, San Francisco, CA, USA"}, :terms [{:offset 0, :value "Regent Thai"} {:offset 13, :value "Church Street"} {:offset 28, :value "San Francisco"} {:offset 43, :value "CA"} {:offset 47, :value "USA"}], :types ["restaurant" "food" "point_of_interest" "establishment"]} {:description "Ebisu Restaurant, 9th Avenue, San Francisco, CA, USA", :id "55ed22b098f6b1b2f1b1d3d1d03d36bc3505d6b3", :matched_substrings [{:length 2, :offset 0}], :place_id "ChIJ93MU4FyHhYARNsN1cMElpgo", :reference "ChIJ93MU4FyHhYARNsN1cMElpgo", :structured_formatting {:main_text "Ebisu Restaurant", :main_text_matched_substrings [{:length 2, :offset 0}], :secondary_text "9th Avenue, San Francisco, CA, USA"}, :terms [{:offset 0, :value "Ebisu Restaurant"} {:offset 18, :value "9th Avenue"} {:offset 30, :value "San Francisco"} {:offset 45, :value "CA"} {:offset 49, :value "USA"}], :types ["restaurant" "food" "point_of_interest" "establishment"]}]

但当我在服务器上检索同样的参数时 这个向量却变成了这个。

{:terms {:offset ["0" "13" "28" "43" "47" "0" "18" "30" "45" "49"], :value ["Regent Thai" "Church Street" "San Francisco" "CA" "USA" "Ebisu Restaurant" "9th Avenue" "San Francisco" "CA" "USA"]}, :types ["restaurant" "food" "point_of_interest" "establishment" "restaurant" "food" "point_of_interest" "establishment"], :matched_substrings {:length ["3" "2"], :offset ["0" "0"]}, :structured_formatting {:main_text ["Regent Thai" "Ebisu Restaurant"], :main_text_matched_substrings {:offset ["0" "0"], :length ["3" "2"]}, :secondary_text ["Church Street, San Francisco, CA, USA" "9th Avenue, San Francisco, CA, USA"]}, :place_id ["ChIJi3wlq2l-j4ARq5Rg0kuektg" "ChIJ93MU4FyHhYARNsN1cMElpgo"], :id ["254f506a2fddd4fecbbbd750e0e91d7871218065" "55ed22b098f6b1b2f1b1d3d1d03d36bc3505d6b3"], :description ["Regent Thai, Church Street, San Francisco, CA, USA" "Ebisu Restaurant, 9th Avenue, San Francisco, CA, USA"], :reference ["ChIJi3wlq2l-j4ARq5Rg0kuektg" "ChIJ93MU4FyHhYARNsN1cMElpgo"]}

为什么会这样,我到底做错了什么?

它们应该是一样的,对吗?

我在Ajax请求中使用了re-frame的http-xhrio。

{:method :post
   :uri "/foobar"
   :params {:my-vec that-vector}
   :on-success [:foo]
   :on-failure [:bar]
   :response-format (edn/edn-response-format)}

而在服务器上,检索是这样的:

(:my-vec (:params req))

打印这个^给出的是以:条款... 开始的地图, 而应该是以[{:描述... ] 开始的向量.

而不是在向量里有两个键位相同的地图,我有的是一个地图,两个地图的所有值都在向量里连成一个地图。

ajax clojurescript re-frame
© www.soinside.com 2019 - 2024. All rights reserved.