# json\_decode

**URL:** <https://community.transloadit.com/t/json-decode/18107>\
**Category:** Transloadit\
**Tags:** tender-archive\
**Created:** [July 10, 2012, 5:33pm UTC](https://community.transloadit.com/t/json-decode/18107 "2012-07-10T17:33:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 10, 2012, 5:33pm UTC](https://community.transloadit.com/t/json-decode/18107/1 "2012-07-10T17:33:00Z")

</div>

> Archived from the Transloadit support forum. Originally posted on July 10, 2012; details may be outdated, see [our docs](https://transloadit.com/docs/) for current behavior. [Original thread](https://web.archive.org/web/20140320112240/http://support.transloadit.com/discussions/problems/820-json_decode)

I’ve recently had plesk upgrade our server to latest php etc and now when I use transloadit the notification is failing at our server end of things (Assembly REDACTED)

If I use json\_last\_error() I get 4 = syntax error. Just wondering if this is something you have come across recently - couldnt’ see anything on your knowledgebase but I’ve come across some discussions elsewhere about new json\_decode issues with PHP

This is my PHP code:

if (!empty($\_POST[‘transloadit’]))  
{

```auto
//----- GET THE TRANSLOADIT DATA -----
$json = $_POST['transloadit'];

```

if (ini\_get(‘magic\_quotes\_gpc’) === ‘1’)

```auto
{
$json = stripslashes($json); //Also fails with this commented out

```

}

```auto
echo "json_last_error is: ".json_last_error()."\n"; //Gives '0'
echo "Doing json_decode"; 

$json = json_decode($json, true);

echo "json_last_error is: ".json_last_error()."\n"; //Gives '4'

```

No worries if not, just asking in case you’ve already had to deal with this

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 10, 2012, 6:33pm UTC](https://community.transloadit.com/t/json-decode/18107/2 "2012-07-10T18:33:00Z")

</div>

Hey adam, sorry you are the first to report this. I can take a deeper look tomorrow, though, if you want.

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 11, 2012, 2:25pm UTC](https://community.transloadit.com/t/json-decode/18107/3 "2012-07-11T14:25:00Z")

</div>

Hi

It turns out the json issue has come about because of a change to my template.  
This is the php code I’m now using:

//----- CHECK TRANSLOADIT CALLED US ----- if (!empty($\_POST[‘transloadit’]))  
{

```auto
//----- GET THE TRANSLOADIT DATA -----
$json = $_POST['transloadit'];

```

if (ini\_get(‘magic\_quotes\_gpc’) === ‘1’)

```auto
{
$json = stripslashes($json);

```

}

```auto
echo "json_last_error before start is: ".json_last_error()."\n"; //Output for debugging info when viewing an assembley in transloadit
echo "Doing json_decode now\n"; 

$json = json_decode($json, true);

echo "json_last_error is now: ".json_last_error()."\n"; //Output for debugging info when viewing an assembley in transloadit

echo "json size is is: ".count($json)."\n"; //Output for debugging info when viewing an assembley in transloadit

```

…

The assembly 937a42bb398c9c5 is using my original template, and it works fine with this php code. I’ve just changed back to it, uploaded a video and in the assembly notification you can see json\_last\_error is now: 0, so all good.

However assembly d985bdb0649764b is using the new template which is an update to the old with video resolution detection in it. This causes json\_last\_error is now: 4  
after the line $json = json\_decode($json, true);

Our server is running PHP5.3.2 . If I give [http://jsonformatter.curiousconcept.com/](http://jsonformatter.curiousconcept.com/) the url of the json I get from your assembly page link it says it is valid, however php5.3.2 is deciding it isn’t. for some reason I appreciate this may not be an issue at all with your end as it may be PHP, but if you have any ideas please let me know

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 11, 2012, 2:38pm UTC](https://community.transloadit.com/t/json-decode/18107/4 "2012-07-11T14:38:00Z")

</div>

I think I have found an indicator for the issue, in the php code I’ve added:

```auto
echo $json;
echo "\n\n\n";

```

before the

```auto
$json = json_decode($json, true);

```

Looking at the echo of the json, after:  
bytes\_usage, my servers echo’d version is different to the one your assembly page is giving

See Assembly REDACTED for the echo (I’ve left it as is for you to see and the php code is still the same on our server if you wish to run it again

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 12, 2012, 7:49am UTC](https://community.transloadit.com/t/json-decode/18107/5 "2012-07-12T07:49:00Z")

</div>

Hm that is weird. : /

The PHP code is a little hard to read as our support app (Tender) messed it up a little. Can you please pastebin it?

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 12, 2012, 7:52am UTC](https://community.transloadit.com/t/json-decode/18107/6 "2012-07-12T07:52:00Z")

</div>

[https://dl.dropbox.com/u/20637505/uploader\_processing\_done\_callback.php](https://dl.dropbox.com/u/20637505/uploader%5Fprocessing%5Fdone%5Fcallback.php)

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 16, 2012, 5:31am UTC](https://community.transloadit.com/t/json-decode/18107/7 "2012-07-16T05:31:00Z")

</div>

Hm I see. I don’t see anything wrong with the code.

I first thought the json was incompletely saved on our end - but it’s all there as you can see here: [http://jsondb.transloadit.com.s3.amazonaws.com/assemblies/REDACTED.json](http://jsondb.transloadit.com.s3.amazonaws.com/assemblies/REDACTED.json)

Do you have any limits set in place in your php.ini that could explain this?

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 16, 2012, 8:43am UTC](https://community.transloadit.com/t/json-decode/18107/8 "2012-07-16T08:43:00Z")

</div>

Hi

I can’t see anything in the php.ini that would cause this - there is a copy of it here:  
[https://dl.dropbox.com/u/20637505/php.ini](https://dl.dropbox.com/u/20637505/php.ini)

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 16, 2012, 12:56pm UTC](https://community.transloadit.com/t/json-decode/18107/9 "2012-07-16T12:56:00Z")

</div>

Doesn’t the  
echo $json; show that transloadit isn’t passing the json data it says it has? The echo is prior to the json\_decode so doesn’t this indicate the cause of the issue?

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 17, 2012, 5:45am UTC](https://community.transloadit.com/t/json-decode/18107/10 "2012-07-17T05:45:00Z")

</div>

Can you please add me on skype? My id is darkangelbge.

I think this will be easier to resolve it in a chat.

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 18, 2012, 11:04am UTC](https://community.transloadit.com/t/json-decode/18107/11 "2012-07-18T11:04:00Z")

</div>

Hi Tim  
Thanks for your help this morning. The more I look at this the more convinced I am that the issue is to do with php5.3.x and the “\<” character being sent in the POST. I can’t find a specific topic on this exact issue online but I’ve found many talking about changes in php5.3.x breaking previously working json. My suspicion is maybe this character isn’t being encoded before being sent or its something else that is only shown when sending to a current php version server. Woudl you be able to update your server to the current release to test this and turn off magic\_quotes\_gpc seeing as it is about to be removed anyway (I’ve put mine back to it being off as there is no point leaving it on going forward)?

---

<div class="post-metadata">

**Author:** ![Felix\_Geisendorfer](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/felix_geisendorfer/32/1463_2.png) [@Felix\_Geisendorfer](https://community.transloadit.com/u/Felix_Geisendorfer)\
**Post date:** [July 21, 2012, 2:35pm UTC](https://community.transloadit.com/t/json-decode/18107/12 "2012-07-21T14:35:00Z")

</div>

Hey Adam, did you figure it out?

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 22, 2012, 1:41pm UTC](https://community.transloadit.com/t/json-decode/18107/13 "2012-07-22T13:41:00Z")

</div>

No. Have you been able to test it using the current version of PHP?

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 23, 2012, 11:44am UTC](https://community.transloadit.com/t/json-decode/18107/14 "2012-07-23T11:44:00Z")

</div>

I tested it using 5.3.8 and it worked fine there. : |

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 23, 2012, 1:15pm UTC](https://community.transloadit.com/t/json-decode/18107/15 "2012-07-23T13:15:00Z")

</div>

OK many thanks for trying it. Very confusing if you also had magic quotes turned off. There doesn’t appear to be any solution for me other than accessing the json file via S3 then. Over the weekend I verified that there is nothing I can do in PHP as the $\_POST is only passed up to the ‘\<’ character so the issue must be occurring prior to the stage of the pages php file getting it. I’m assuming there is no alternate to the \< and \> characters in the transloadit templates (there isn’t a word based equivalent?)

Many thanks  
Adam

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [July 23, 2012, 1:36pm UTC](https://community.transloadit.com/t/json-decode/18107/16 "2012-07-23T13:36:00Z")

</div>

Hey Adam,

nope unfortunately there is no alternative characters at the moment. The only safe way for you right now is to get the json from the jsondb url.

Sorry again for the trouble and for not finding any better solution.

Kind regards,  
Tim

---

<div class="post-metadata">

**Author:** ![Felix\_Geisendorfer](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/felix_geisendorfer/32/1463_2.png) [@Felix\_Geisendorfer](https://community.transloadit.com/u/Felix_Geisendorfer)\
**Post date:** [July 24, 2012, 4:18pm UTC](https://community.transloadit.com/t/json-decode/18107/17 "2012-07-24T16:18:00Z")

</div>

Are you using any PHP extensions that could cause this? Or the Suhosin / hardened PHP patch?

---

<div class="post-metadata">

**Author:** ![Adamski11](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Adamski11](https://community.transloadit.com/u/Adamski11)\
**Post date:** [July 24, 2012, 4:21pm UTC](https://community.transloadit.com/t/json-decode/18107/18 "2012-07-24T16:21:00Z")

</div>

Hi  
Only the tinybutstrong template engine, but that isn’t really a php extension. I’ve been trying to see if it could be the cause but I’ve not managed to find anything so far…

---

<div class="post-metadata">

**Author:** ![tim-kos](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tim-kos](https://community.transloadit.com/u/tim-kos)\
**Post date:** [September 4, 2012, 8:28am UTC](https://community.transloadit.com/t/json-decode/18107/19 "2012-09-04T08:28:00Z")

</div>

I am marking this ticket as resolved for now. please feel free to reply to it - it will reopen then automatically.

Kind regards,  
Tim

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex032/uploads/transloadit/original/1X/04ee57da0cb7ac8728a9ac5965c288164f4ce280.svg) [@system](https://community.transloadit.com/u/system)\
**Post date:** [October 7, 2026, 10:08am UTC](https://community.transloadit.com/t/json-decode/18107/20 "2026-10-07T10:08:58Z")

</div>


