I am trying to read a perl associative array in my PHP script. For this firstly I am trying to convert perl hash to JSON using JSON module.
Below is the perl script I am using to convert associative array to JSON. The file toc.pl has the associative array "asc_array".
use JSON;
$j = new JSON;
require'toc.pl';
print encode_json \%asc_array;
The asc_array looks like
%asc_array = (
"1" => 'Introduction',
"1.1" => 'Scope',
"1.2" => 'Purpose',
"2" => 'Terminology',
"2.1" => 'Definitions',
"2.2" => 'Service Primitives',
"2.3" => 'Abbreviations',
"2.4" => 'Acronyms',
);
Here I am facing an issue and that is after converting it to JSON the order of associative array elements change.
So my question is How can I keep the order of elements even after converting it to JSON?
And, after converting it to JSON I am reading the JSON in PHP script.
Is there any better way to read perl associative array in PHP script?