これはこれまでにない最も疑問な質問ですが、このShopify APIレスポンスから値を引き出すにはどうすればよいですか?Shopifyレスポンス配列から値を引き出す
orders = [#<ShopifyAPI::Order:0x007fb987a4f900 @attributes={"id"=>4141918472, "email"=>"[email protected]", "created_at"=>"2016-09-28T14:12:49-05:00", "total_price"=>"109.99", "order_number"=>1001, "billing_address"=>#<ShopifyAPI::BillingAddress:0x007fb987a4e410 @attributes={"first_name"=>"John", "address1"=>"111 Fake St", "phone"=>nil, "city"=>"Los Angeles", "zip"=>"90210", "province"=>"California", "country"=>"United States", "last_name"=>"Doe", "address2"=>"", "company"=>nil, "latitude"=>34.0670499, "longitude"=>-118.2714165, "name"=>"John Doe", "country_code"=>"US", "province_code"=>"CA"}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>, #<ShopifyAPI::Order:0x007fb987a46b98 @attributes={"id"=>4141925128, "email"=>"[email protected]", "created_at"=>"2016-09-28T14:14:25-05:00", "total_price"=>"309.97", "order_number"=>1002, "billing_address"=>#<ShopifyAPI::BillingAddress:0x007fb987a456f8 @attributes={"first_name"=>"afd", "address1"=>"744 Fake", "phone"=>nil, "city"=>"Chicago", "zip"=>"60021", "province"=>"Illinois", "country"=>"United States", "last_name"=>"adsfasd", "address2"=>"", "company"=>nil, "latitude"=>42.1976923, "longitude"=>-88.2120315, "name"=>"afd adsfasd", "country_code"=>"US", "province_code"=>"IL"}, @prefix_options={}, @persisted=true>}, @prefix_options={}, @persisted=true>]
私はorders.classを使用しました。それは配列だと言います。これはハッシュの配列ですか?私は.to_jsonを使うことができますが、注文[0] .to_json ['email']はメールを返します。私は注文[0] [1]と注文[0] ['id']のようなものを試しました。しかし、私は何もすることはできません。私は何が欠けていますか?
とあなたが得るものを見ます。 –
また、# –
Adam12344
を試してみました。 'orders.first.email'を試してみてください。 APIは、属性を直接メソッドにマップする必要があります。したがって、 'orders.first.email/order_number/billing_address'などはおそらく動作します。 – Casper