No video

What is the difference between JSON and PHP Serialize

  Рет қаралды 1,513

Joshua Herbison

Joshua Herbison

Күн бұрын

A brief explanation of the differences between JSON and Serialize.
#json #serialize #php_development

Пікірлер: 25
@jherbison
@jherbison 2 жыл бұрын
Let me know if I need to expand on this... I wanted to briefly touch on the differences.
@anirudhachakrabarty2050
@anirudhachakrabarty2050 Жыл бұрын
Yes please... I have come up with a scenario.. Where I have a datatable where I fetch filtered data from orders. And I want to select some rows for refund. Like from that datatable I want to select some rows as refund request. And Want to put an extra user input column where the executive can put from where that request came from like call or email just a input text. I wnt those checkbox selected rows data to save in another table named refund request. I am able to select that and get the id but can't able to get the values of all the column values for that selected rows.. I used php jQuery Ajax... How can I send those entire row values? Can you please help?
@srdjagunjic
@srdjagunjic 2 жыл бұрын
Awesome video
@jherbison
@jherbison 2 жыл бұрын
Thank you!
@user-gb8yn5zp2z
@user-gb8yn5zp2z 2 жыл бұрын
LOVE ❤ This tutor! 🌟
@jherbison
@jherbison 2 жыл бұрын
Thank you!
@user-ly6ws7cz7n
@user-ly6ws7cz7n 2 жыл бұрын
Great! I need tutorials wp development non-standart themes and plugins! It's needed all over the world🌏 developers
@jherbison
@jherbison 2 жыл бұрын
Thank you
@UrielSoto
@UrielSoto 2 жыл бұрын
Thanks for the video!
@dashingpix
@dashingpix 2 жыл бұрын
Another great one, thanks bro :) As you touch on JSON, now why cant we explore @wordpress/scripts, and how we can utilize/use React on WordPress in the Wordpress way with WP REST API. Just a suggestion, if possible :)
@jherbison
@jherbison 2 жыл бұрын
Awesome.. Thank you for watching and commenting.. I will add that to the list of videos to make.
@V3ritas1989
@V3ritas1989 2 жыл бұрын
Greate timing, I have a follow up. So today I stumbled uppon people having placed serialized data into the DB. Which is totally annoying for what I want to do because now I cannot just write a bigger mysql query to pull the data with calculations and grouped in the format how I need it. But I will probably need to write at least 300 lines in php instead of simple 30 lines in sql. Which would also be way more readable than doing all these calculations during loops in php. Specifically, this is about delivery costs for purchase orders for each supplier by country, that have been entered serialized in the supplier table. So my question. Should people be doing this? Cause now I can't use "group by" and probably need to loop through thousend of orders every time I want to do the analysis. Which takes way longer in PhP than in the 3 second sql query... So, where should people use serialized data and where shouldn't they?
@jherbison
@jherbison 2 жыл бұрын
Thank you for the question. So it is great to have the data serialized, but yes it can make it difficult or slow to process a database query. If you have access to the code when the order is placed, you could separate those details and put them in as separate data. If not, but you have access to the database: You could run a script (maybe a cron) that would separate out the data you need and put that into a separate table even like as a taxonomy table. New table could be column1:order_id and column2:country. Make sure both columns are indexed (order_id being unique) and then you would be able to quickly do a query when you need to based on country. You could also do that for any searchable data.. Maybe the second column is country, maybe it is "value", but then you would need to make sure that order_id isn't unique, but maybe add an ID that is unique, as it won't let you put in two rows with the same order_id. Hope that isn't confusing and helps!
@aogunnaike
@aogunnaike 2 жыл бұрын
Awesome content, when do you decide as a developer to build a feature as a plugin or with the custom theme? Thanks
@jherbison
@jherbison 2 жыл бұрын
Great question.. Thank you. Typically, we build all customization in plugins. That way if they decide to change the look, we don't have to bring over all the customization to a new theme.. The plugins should always be able to work on any site. Thank you for watching and commenting..
@user-ly6ws7cz7n
@user-ly6ws7cz7n 2 жыл бұрын
@@jherbison Interesting!👍
@jherbison
@jherbison 2 жыл бұрын
Thank you.
@amirgohary1999
@amirgohary1999 Жыл бұрын
Hi Joshua Thanks for the great video Actually I am willing to send array from $_POST form to mysql. Just I need to know the best way to send this array as serialized or JSON I see someone here, is mentioned that "Serialization in PHP can be corrupted easily if you save it to database "
@wiktorliszkiewicz354
@wiktorliszkiewicz354 2 жыл бұрын
Serialization in PHP can be corrupted easily if you save it to database and string replace without changing serialization variable length. No such issue with JSON. And if you need to encode user data as JSON you might simply escape data before pushing it to JSON. This is the main reason why you can not simple search and replace MySQL dump SQL file while migrating to another domain, because it will brake serialized data if such is present.
@philip9677
@philip9677 2 жыл бұрын
When should we use Json and when should we use serialize
@jherbison
@jherbison 2 жыл бұрын
Always use serialize if saving to the database or sending to another php application. Use json if you don’t know what the other application format will be or if you know for sure it isn’t php.
@philip9677
@philip9677 2 жыл бұрын
@@jherbison Thanks Josh, am actually just starting to learn php, the tutorials are awesome
@jherbison
@jherbison 2 жыл бұрын
@@philip9677 Thank you.. That is great that you are starting to learn php.
@crowbr
@crowbr Жыл бұрын
Have some way in javascript to serialize like a PHP, i need pass a array to api and this request its a PHP serialize format not JSON.stringfy :z
Using GET or POST, When, Why and How to get the data in PHP
14:32
Joshua Herbison
Рет қаралды 744
Is JSON Blazingly Fast or...?
9:57
ThePrimeagen
Рет қаралды 190 М.
Harley Quinn's revenge plan!!!#Harley Quinn #joker
00:59
Harley Quinn with the Joker
Рет қаралды 26 МЛН
Create a Shortcode Plugin that uses ob_start() function to return data
15:19
PHP Serialization Tutorial | Serialize and Unserialize PHP Objects
12:00
PHP Serialization
14:59
Christian Hur
Рет қаралды 2,3 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
What Is JSON | Explained
5:44
Hostinger Academy
Рет қаралды 45 М.
Serialization - A Crash Course
8:14
0612 TV w/ NERDfirst
Рет қаралды 124 М.
A Day in the Life of a Self Employed Software Engineer
7:40
Joshua Herbison
Рет қаралды 17 М.
How to create a WordPress Gutenberg Custom Block
42:09
Joshua Herbison
Рет қаралды 48 М.
How to use JSON in PHP - In 5 Minutes
4:49
Daily Tuition
Рет қаралды 23 М.
Parsing Explained - Computerphile
14:58
Computerphile
Рет қаралды 241 М.