Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
30 Jun 2011 at 01:03 UTC
Updated:
29 Jul 2014 at 19:44 UTC
Jump to comment: Most recent file
Comments
Comment #1
keichee commentedfirst patch..
no issues after installation and further testing..
Comment #2
marcingy commentedEm why?
Comment #3
keichee commentedbecause json is much better* than serialize
*better means:
no more conversion when transferring data from php to javascript and vice versa
much more cleaner looks
objects are easier, faster to code rather than array.
minimal coding is required comparing arrays vs json in php and javascript.
even this wont be approved to core instantly, can someone please initiate the simple test if it fails or succeed?
Comment #4
marcingy commentedSerialised is straight forward and simple there is no rational reason to do this.
Comment #5
marcingy commentedActually...
Comment #7
keichee commentedwow.. thanks..
Comment #8
keichee commentedComment #9
marcingy commentedMarking as won't fix because this is sounding like changes for changes sake.
Comment #10
keichee commentedim still trying to make a patch, seems like drupal_json_encode and decode looks like changing arrays to objects that's why i changed the subject.
Comment #11
marcingy commentedNo json handles both arrays and objects. The issue is that it can't handle mixed cases so an object that contains array will not work - serialise can handle this case hence the won't fix. Plus this change negates your argument about array compares.....
Serializing data is much simpler in php as it is native representations of php data, there is really no benefit of converting json functions.
Comment #12
keichee commentedthis patch is really _worth_ it.. at last no more serialize, deserialize
database saves blobs as json strings
and fixed array_map syntax error bugs
deleted unnecessary replace functions in drupal_json_encode
checked in mysql and sqlite installations = working flawless
hope this patch will be applicable too to D7 and D6
please check and hope to implement after majority agrees ^_^
Comment #13
damien tournoud commentedjson_encode()/json_decode()is *not* equivalent withserialize()/unserialize():json_encode(chr(255)), for exampleThis is definitely not something that can be backported to neither Drupal 7 nor Drupal 6 (because *all* the objects currently stored in the database will have to be changed). For Drupal 8, this is a duplicate of #839444: Make serializer customizable for Cache\DatabaseBackend, if you want to make a case for
json_encode()vs.serialize()you will have to prove (by benchmark of otherwise) that even with its limitationsjson_encode()is better.Comment #14
keichee commentedcan someone please initiate testing to my patch?
Comment #15
keichee commentedplease download the benchmark at
https://github.com/jbergstroem/instabench
please download the php version PHP 5.4.0alpha1 (latest version) in PHP
The latter handles most of the PHP data structures, while the former only handles Javascript arrays (a type of data that doesn't exist in PHP) and Javascript plain objects (that are relatively similar to PHP arrays).
> i think there are two PHP data structures, arrays and objects which json handles better
The latter is binary safe, while the former only handles valid Unicode strings (try json_encode(chr(255)), for example
> if there will be error in the code, i will later all invalid unicode strings to json friendly version
please do see the benchmark as serialize are intensively used by drupal, if this benchmark is correct, drupal will be 2.7x faster
i definitely want to choose 2.7x faster drupal and later problem unicode strings like chr(255)
how about others?
please check attached patch if will succeed, many thanks
Comment #17
damien tournoud commentedThis is still a duplicate of #839444: Make serializer customizable for Cache\DatabaseBackend. Please don't open that issue again.
Comment #18
keichee commentedposted on the duplicate issue, hopefully patch will succeed to core