Здравствуйте, у меня есть тело запроса:
CURLOPT_POSTFIELDS => "{\n
\"data\": {
\n
\"type\": \"orders\",\n
\"attributes\": {\n
\"docNo\": \"$order_num\",\n
\"date\": \"2022-06-07\",\n
\"description\": \"$preferences\",\n
\"budget\": 0,\n
\"dueTime\": null,\n
\"delivery\": $delivery,\n
\"deliveryComments\": \"\",\n
\"deliveryCity\": \"\",\n
\"deliveryStreet\": \"\",\n
\"deliveryHouse\": \"\",\n
\"deliveryApartment\": \"\",\n
\"deliveryTimeFrom\": null,\n
\"deliveryTimeTo\": null,\n
\"deliveryContact\": \"\",\n
\"deliveryPhoneCode\": \"\",\n
\"deliveryPhoneNumber\": \"\",\n
\"createdAt\": null,\n
\"fiscal\": false,\n
\"byBonuses\": true,\n
\"deliveryStatus\": null\n
},\n
\"relationships\": {\n
\"store\": {\n
\"data\": {\n
\"type\": \"stores\",\n
\"id\": \"de77d6a3-bdf6-4637-9f6b-7b7fe9d0338f\"\n
}\n
},\n
\"source\": {\n
\"data\": {\n
\"type\": \"order-sources\",\n
\"id\": \"9bed7b59-94dc-4ce4-aac2-883aab1a148c\"\n
}\n
},\n
\"createdBy\": {\n
\"data\": {\n
\"type\": \"workers\",\n
\"id\": \"2d10e9f0-96d5-46f7-bd59-3f85f7b80fe3\"\n
}\n
},\n
\"lines\": {\n
\"data\": [\n
$result2
]\n
}\n
}\n
}\n
}",
Мне нужно в это место поместить переменную, в которой находится другой json:
{\n \"id\": \"594c2da3-24f2-4faa-96e0-d6e41ddab2ef\",\n \"type\": \"order-lines\",\n \"attributes\": {\n \"qty\": 1,\n \"price\": 1200,\n \"totalAmount\": 0,\n \"totalAmountWithDiscount\": 0\n },\n \"relationships\": {\n \"item\": {\n \"data\": {\n \"type\": \"inventory-items\",\n \"id\": \"29d85f91-e47c-4dc0-bdf2-a3a74acb9cb2\"\n }\n }\n }\n }
Как можно это сделать? Я пытался через конкатенацию, ничего не выходит. Пытался просто переменную вставить, тоже самое. Выдает ошибку Unable to parse JSON data","detail":"JSON_ERROR_SYNTAX - Syntax error, malformed JSON"