Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize() vs json_encode() #82

Open
lsmith77 opened this issue May 1, 2021 · 6 comments
Open

serialize() vs json_encode() #82

lsmith77 opened this issue May 1, 2021 · 6 comments

Comments

@lsmith77
Copy link

lsmith77 commented May 1, 2021

just wanted to know if there is a particular benefit that made you prefer serialize() over json_encode() ? I am currently looking into doing some analytics and machine learning over the versions and it would be convenient to be able to use JSON RDBMS functions to examine the data etc.

in this spirit would you be open to a PR that makes it optional if the encoding is done with serialize() or json_encode() ?

@nonoesp
Copy link
Collaborator

nonoesp commented May 4, 2021

Hey, @lsmith77!

This would be a question for @mpociot, who is the original author. Is the size bigger as JSON than as a binary?

I'd be willing to play with this and look at the differences if you open a pull request.

@lsmith77
Copy link
Author

lsmith77 commented May 4, 2021

thx. here are some benchmarks that can help on this topic https://niden.net/post/fast-serialization-of-data-in-php/

@nonoesp
Copy link
Collaborator

nonoesp commented May 5, 2021

It does seem to be a lot faster!

@lsmith77
Copy link
Author

lsmith77 commented May 5, 2021

BTW I am not sure if with JSON there might be a risk that the decoded data does not match the encoded data, ie. array vs. objects and null handling. so I think likely if at all, we want to make this an option

@lsmith77
Copy link
Author

FYI still haven't had time to work on this .. but I just had another use case pop up for JSON:
I just renamed "is_hidden" to "is_shown", now I would like to update the version history to reflect this renaming.
With JSON I could just write an SQL query to do this.

@nonoesp
Copy link
Collaborator

nonoesp commented May 20, 2021

FYI still haven't had time to work on this .. but I just had another use case pop up for JSON:
I just renamed "is_hidden" to "is_shown", now I would like to update the version history to reflect this renaming.
With JSON I could just write an SQL query to do this.

Nice! That use case makes a lot of sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants