You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It takes 0.00051963460445404 seconds to get the properties each time on php 8.1, because it needs to call the json_decode function each time to parse the string into an array.
Now there are two ways to solve this problem:
introduce a local temporary variable
add a cache to the model to temporarily store the converted properties
The first solution is fine for shorter contexts where we can reuse temporary variables, but it is not a good solution if we need to use the json properties of the model in a different context. Personally, I think the second solution is a better solution, but it may also bring code complexity.
I would like to hear if there is a better solution for everyone. My English is not very good, I need to use the translation software to communicate with everyone, if there is a description of inaccurate places hope you understand.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We have a json usage scenario with the following code:
It takes 0.00051963460445404 seconds to get the properties each time on php 8.1, because it needs to call the json_decode function each time to parse the string into an array.
Now there are two ways to solve this problem:
The first solution is fine for shorter contexts where we can reuse temporary variables, but it is not a good solution if we need to use the json properties of the model in a different context. Personally, I think the second solution is a better solution, but it may also bring code complexity.
I would like to hear if there is a better solution for everyone. My English is not very good, I need to use the translation software to communicate with everyone, if there is a description of inaccurate places hope you understand.
Beta Was this translation helpful? Give feedback.
All reactions