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

fix(JSON): Fix nested json #29

Closed
wants to merge 2 commits into from
Closed

Conversation

silbinarywolf
Copy link
Contributor

@silbinarywolf silbinarywolf commented Aug 6, 2018

Related Issue:
#28

This is currently broken on purpose. So far this just has the test case in.

Whats left to do:

  • Update the $expectedHTML for testJSONDeeplyNested to be what the HTML output should be.
  • We need to update the outputting of a SilverStripe template so that instead of using var_export($value, true) to get PHP code of an array with nested arrays, we simply walk the entire array structure and generate the needed PHP code.

How to recursively walk an array structure

<?php
// Iteration on leafs AND nodes
foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($candidate), RecursiveIteratorIterator::CATCH_GET_CHILD) as $key => $value) {
    echo 'My node ' . $key . ' with value ' . $value . PHP_EOL;
}

Source: http://php.net/manual/en/function.array-walk-recursive.php#116876

@JoshuaCarter
Copy link
Contributor

Closing due to:
#30
#31

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

Successfully merging this pull request may close these issues.

2 participants