We will check with our developers if there is any possible typo on that part of the Documentation. If there is, they will fix it as quickly as possible. I am just not fully understanding what you asked in this part :?
‘What value of the param will we get as a result? Is that how it should be?’
We will do our best to advise you on what those hooks are used for, etc.
As our developers pointed out in this example on our Documentation?,
if we only choose up to the first level deep in the JSON roots from our sample Nested JSON file?, such as “root>results”,
then it works without any additional step needed.
There is this part of the Documentation beneath the example, where our devs stated :
Please note: The root path that is chosen, needs to have the same object with the same keys and values as you can see for chosen path “root->results”.
If values are not a string, then those values will be skipped by default.
In this case keys “films”, “vehicles”, “starships”, and “species” have values as arrays (in some cases they can be objects) and they will not be shown.
If you need to show data from those arrays as well, there is an option with a hook.
So, when one of the chosen root path objects contains keys that have an array or objects as values
and you need to include them in a table as cell values, then you can choose from these two hooks:
find the title as “Use hooks to parse one more level deep in root path”.
There you will find the detailed explanation how you can use this hook to access one more leel deep in your JSON root path.
As for the specific part you asked, the parameters : For the first hook that accepts 3 params.
First param(parameter) is $deepParse – boolean – false by default. 2. Second param is $jsonURL – string – nested JSON URL. 3. Third param is $tableID – int – id of the table. You only need to provide a boolean value true, please check our example from that Page.
Please note that using hooks requires certain level of programming skills and included support refers only to advice.
You can get a detailed description of WordPress hooks here in WP Codex
I hope this helps.
This reply was modified 1 month ago by wpDataTables.
Whoa, whoa, whoa… take it easy, man! I just wanted to make sure that $deepParse is false by default. Because when I don’t change the state of $deepParse, then deep parse is triggered as a true deep parse and everything works fine! That’s all.
Hello Vladimir, My sincere apologies, we did not understand what you intended to ask initially. Now we realize it, sorry about that. Thank you for the clarification. We spoke with our developers again, they advised. It is not a typo since it returns what is in the $deepParse, which is ‘false’ by default as you wrote.
If you need to change the logic for a specific condition, you can write it as we did in the example from the Documentation :
function parseNestedJSON($deepParse, $jsonURL, $tableID){ //use only for tables that have specific json url if($jsonURL == ‘https://swapi.dev/api/people’){ return true; } return $deepParse; }
Where when the condition is met, it returns it as ‘true’ and it exits the function. In that case, it does not get to the “return $deepParse;” It can be written in a different way as well, if needed for clarification, for example :
function parseNestedJSON($deepParse, $jsonURL, $tableID){ //use only for tables that have specific json url if($jsonURL == ‘https://swapi.dev/api/people’){ $deepParse = true; } return $deepParse; }
In this case, it would be written in the variable $deepParse and returns as ‘true’. Once again, my apologies for writing so many details in the original reply, we did not understand the question right away.
Hi Vladimir, You’re welcome, we are happy to advise. Please don’t hesitate to open new Posts if anything else comes up that we should check. Thank you.