我正在使用 guzzle 包从 API 接收 JSON 数据。我要存储在数据库中的接收数据:
我的数据保存到数据库代码:
$contents = json_decode($response->getBody());
$object = new Product();
$object->GeneralInfo = $contents->data->GeneralInfo;
$object->save();
return response()->json($contents);
我收到的异常:stdClass 类的对象无法转换为字符串
我知道它想要存储正在传递的字符串和对象。存储这些数据的最佳方式是什么?转换为数组可能吗?提前感谢您的提示。
跃然一笑
陪伴而非守候
随时随地看视频慕课网APP