Json_decode doesn't work as intended inside Kirby template

Trying to use json_decode on a simple json string inside a Kirby template doesn’t give me any errors, but it doesn’t parse correctly, either. Here’s the code:


$data = '{
	"data": {
		"title": "Title",
		"question": "Essential question",
		"text": "<p>Body text<\/p>",
		"images": [{
			"url": "\/content\/1-curriculum\/1-biotechnology\/biotechnology.jpg",
			"width": 960,
			"height": 640,
			"thumbs": {
				"large": "\/thumbs\/curriculum\/biotechnology\/biotechnology-720x480-q70.jpg",
				"small": "\/thumbs\/curriculum\/biotechnology\/biotechnology-360x240-q50.jpg"



Here’s how it looks as a Kirby template:


When I run the exact same code as a standalone php file on the root of the same server, it parses fine. Here’s how it looks:


What am I missing?

Your code just works here. This is the output of var_dump(json_decode($data)->data);, from a template file on my dev setup:

  public 'title' => string 'Title' (length=5)
  public 'question' => string 'Essential question' (length=18)
  public 'text' => string '<p>Body text</p>' (length=16)
  public 'images' => 
    array (size=1)
      0 => 
          public 'url' => string '/content/1-curriculum/1-biotechnology/biotechnology.jpg' (length=55)
          public 'width' => int 960
          public 'height' => int 640
          public 'thumbs' => 

Yes, works for me as well.

Argh! Thanks for the replies. I just did a one-by-one check to see if a plugin was causing the problem, and of course it’s the kirby-html-minifier plugin I only recently enabled. Should have guessed that.

Thanks for your help and my apologies for not checking this first!