Closed (fixed)
Project:
Kaltura
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
30 Dec 2008 at 22:51 UTC
Updated:
18 Jan 2009 at 07:50 UTC
There is no need to use json_encode() when Drupal core code define the drupal_to_js() which does the same task. There isn't then the need to use a third party routine, if the module is running on a PHP4 installation.
Comments
Comment #1
Zohar.Babin commentedGot 2 problems with that replacement.
I'm using JSON to create a string of variables which I pass in the query string.
the drupal_to_js function returns something similar to json_encode but with extra (and a lot) spaces.
I could remove these spaces when going to decode, but I can't see a decoding function (which leaves me either with json_decode and back to PHP5 requirement or using 3rd party tool, or to reverse the drupal_to_js function...)
Comment #2
avpadernoUsually, the data encoded using JSON is supposed to be read by JavaScript code, and that is the reason there isn't a function to decode the encoded data; the data
drupal_to_js()returns is in the format that JavaScript can directly use.Comment #3
Zohar.Babin commentedwell, in my case I'm using JSON for another purpose, and encoding to JSON without the ability to decode will be worthless...
I'd consider using serialize() (although it takes about x1.4 more chars) since it's using the same chars eventually.
Comment #4
avpadernoIf the data you encode with
json_encode()is not being used by JavaScript, then there is not reason to use that function.If the data is being used only by PHP, then
serialize()is the right function to call, also because is always present in all versions of PHP.Comment #5
Zohar.Babin commentedI understand and accept this. the only reason I went towards JSON is that it's shorter than serialize, and since I'm passing it in the URL as a page argument shorter is better to avoid any $_GET length limitations.
Comment #6
Zohar.Babin commentedChanged the relevant fnuction to use serialize() instead of JSON.
The JSON class (for PHP4 support) will be removed.
All changes will be applied on the next release