我想解析类似的东西:
{
"OutputDocumentType": "receipt",
"ParsedFields": {
"smart_tags": "R°\nVul\nZe",
"vendor": "",
"vendor_terms": "",
"vendor_warranty": "",
"vendor_support": "",
"vendor_url": "",
"expense_category": "General Retail",
"tracking_no": null,
"carrier_name": null,
"tracking_link": null,
"tracking_status": null,
"shipping_speed": null,
"date_shipped": null,
"date_estimated": null,
"shipping_address_street_1": null,
"shipping_address_street_2": null,
"shipping_address_state_province": null,
"shipping_address_city": null,
"shipping_address_zip": null,
"shipping_phone": null,
"shipping_mobile": null,
"shipping_fax": null,
"account": "",
"purchase_confirmation_no": "",
"purchase_order_no": "",
"purchase_time": "",
"purchase_invoice_no": "",
"purchase_invoice_date": "",
"purchase_discounts": "",
"subtotal_amount": "",
"shipping_cost": "",
"purchase_warranty": "",
"transaction_id": "",
"payment_address_street_1": "",
"payment_address_street_2": "",
"payment_address_city": "",
"payment_address_state_province": "",
"payment_address_zip": "",
"payment_phone": "",
"payment_mobile": "",
"payment_fax": "",
"receipt_date": "",
"payment_type": "Cash",
"total_amount": "$16.95"
}
}
但是当我尝试在tracking_no
失败时,因为值为null
。如何才能使用null
值?
答案 0 :(得分:2)
只需将地图Map[String,Option[String]]
解析即可。