0

I am trying to export some data from a php script to load into arborjs, problem is the php json_encode encapsulates the node and edge objects in square brackets [], which upsets arborjs.

json_encode gives:

{"nodes":[{"10":{"auth":"EP","depth":0}}]}

but arborjs wants

{"nodes":{"10":{"auth":"EP","depth":0}}}

Anyone else encountered and solved it?

1 Answer 1

0

Issue was with array_push

$n=array($key=>$value);
array_push($array,$n);

does not preserve keys, instead using:

array_push($array[$key]);
$array[$key]=$value;

works, preserving keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.