By editor, 20 November, 2015 Question How to provide json array as result of service or as output page. You can do that using Symfony JsonResponse. Exemple 1. return new \Symfony\Component\HttpFoundation\JsonResponse($array); Exemple 2. use Symfony\Component\HttpFoundation\JsonResponse; public function get_result() { $output = array(); $output[] = array('time' => date("Y-m-d H:i:s")); $output[] = array('result'=> "OK"); return new JsonResponse($output); } Tags Drupal 8 Code JSON Comments You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically.
Comments