I need a little help about arrays+json+ajax

I need a little help about arrays+json+ajax

Hello, I am developing an application that creates a series of menus from a database and collected json.

Here you can see my development. although, the submenus are created manually.

the JSON array I get is the following: ["Option1", "Option2", "Option3", "Option 4"] 

I was trying to do the JSON array like this: 
Note: the number that appears next to the subcategory indicates the amount of files that have that category.



code:  { "Menu1": { "SubMenu1": { "Category1": "0", "Category2": "0", "Category3": "0" }, "SubMenu2": {} }, "Menu2": { "SubMenu1": { "Category1": "0", "Category2": "0", "Category3": "0" }, "SubMenu2": {} } }

but someone told me I was making an object, not an array. so did this after: 

code:  { "Menu1": { "Submenu1": [ { "Category1": "5"}, { "Category2": "15"}, { "Category3": "8"} ] }, "Menu1": { "Submenu1": [ { "Category1": "4"}, { "Category2": "2"}, { "Category3": "8"} ] } }

Could anyone help me? I would love to resolve this issue because it is blocking me enough. 

What I need is to create in php a correct JSON array. And get it with AJAX and create menus and submenus from that JSON array. The problem is that I'm pretty lost and the headache does not help very ...

Thank you in advance