Hi
If you can show us the nested object it would help, just copy and paste using 3 tilde signs before and after the entry so that the it looks more readable. I will take what you had above and put it between tilde (the key next to number 1) so that you can see what it looks like:
{ "name": "test", "description": "test", "startdate": "2016-02-21T13:00:00.000Z", "enddate": "2016-02-23T13:00:00.000Z", "coach":
{ "uuid": "76fdd664-d830-11e5-9d46-00ffc9587cbc" }, "category":
{ "uuid": "771e6de4-d830-11e5-9d46-00ffc9587cbc" }, "useruuid": "76d65a2d-d830-11e5-9d46-00ffc9587cbc", "routines":
["775b2726-d830-11e5-9d46-00ffc9587cbc"] }
on your controller
$request->json();
will get you the json request as an array
$request->json()->name
Hi @astroanu ... I know how to get the value from the parent object as you said.
AtomicRSA said:
Hi
If you can show us the nested object it would help, just copy and paste using 3 tilde signs before and after the entry so that the it looks more readable. I will take what you had above and put it between tilde (the key next to number 1) so that you can see what it looks like:
{ "name": "test", "description": "test", "startdate": "2016-02-21T13:00:00.000Z", "enddate": "2016-02-23T13:00:00.000Z", "coach": { "uuid": "76fdd664-d830-11e5-9d46-00ffc9587cbc" }, "category": { "uuid": "771e6de4-d830-11e5-9d46-00ffc9587cbc" }, "useruuid": "76d65a2d-d830-11e5-9d46-00ffc9587cbc", "routines": ["775b2726-d830-11e5-9d46-00ffc9587cbc"] }
If you look at the JSON above, the coach, the category and routines are nested object.
I found away to do this nested JSON object thingy but not elegant :)
There gotta a better way to handle this
Well i displayed nested objects in a view like this and i think it should work for you:
$data->name
$data->coach->uuid
$data->coach->category->uuid
dcalliances said:
I found away to do this nested JSON object thingy but not elegant :)
$data = $request->json()->all();
// Log::debug($request);
// $phpArray = json_decode($data,true);
$name = $data['name'];
$coach_uuid = $data['coach']['uuid']; // works now !!!
$category_uuid = $data['category']['uuid']; // works now!!!
There gotta a better way to handle this
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community