!map:HashWithIndifferentAccess转换为JSON或其他格式

时间:2015-06-04 06:21:00

标签: ruby-on-rails hash

当我通过rails控制台查询以获取发票的数据时。它返回一个!map:HashWithIndifferentAccess文本。见下面的例子。

  

“---!map:HashWithIndifferentAccess \ nformat:xml \ ninvoice:   !map:HashWithIndifferentAccess \ n reference:5-00000003R \ n   invoice_lines:\ n - !map:HashWithIndifferentAccess \ n价格:   \“2.50 \”\ n product_id:\“177698 \”\ n数量:\“ - 1.00 \”\ n
  discount_text:10%\ n retail_price:\“25.00 \”\ n小计:   \“ - 2.50 \”\ n付款:\ n - !map:HashWithIndifferentAccess \ n
  payment_type_id:\“6 \”\ n金额:\“ - 20.09 \”\ n招标:   \“ - 20.09 \”\ n invoice_date:\“2015-06-04T05:56:44Z \”\ n备注:   取消订单\ n customer_id:\“182029 \”\ n tax_inclusive:   \“true \”\ n invoice_tax_rates:\ n - !map:HashWithIndifferentAccess \ n   rate:\“0.12 \”\ n amount:\“0.27 \”\ naction:create \ ncontroller:   api_invoices \ n“个

我需要的是在发票的发票行属性中获取所有产品ID。我该如何解析这个文本?

0 个答案:

没有答案