【问题标题】:How to access value in Json Object Laravel Blade如何在 Json Object Laravel Blade 中访问值
【发布时间】:2021-07-22 10:58:22
【问题描述】:

我只想访问这个 json 对象中的“Elevator”值。 如何在 Laravel 刀片模板中做到这一点?

谢谢!

{"delivery_floor":null,"pickup_floor":null,"Elevator":"Yes","Elevator2":"Yes","disassembled":"Yes","reassembled":"Yes","shipment_title":""}

【问题讨论】:

  • 你试过解码payload吗? json_decode('{"delivery_floor":null,"pickup_floor":null,"Elevator":"Yes","Elevator2":"Yes","disassembled":"Yes","re​​assembled":"Yes","shipment_title ":""}')

标签: json laravel laravel-blade


【解决方案1】:

您必须使用以下代码

@php $jsonDecodeValue = json_decode($your_variable,true); @endphp
{{ $jsonDecodeValue['Elevator']}}

【讨论】:

  • 如果您想将属性作为关联数组而不是作为数组访问,则必须将 associative 标志(json_decode 中的第二个参数)设置为 true。跨度>
猜你喜欢
  • 1970-01-01
  • 2020-01-12
  • 1970-01-01
  • 2017-08-31
  • 1970-01-01
  • 2018-02-21
  • 1970-01-01
  • 2017-10-08
  • 1970-01-01
相关资源
最近更新 更多