{% layout none %} [ {% for menu in linklists %} { "menu": { "title":"{{ menu.title }}", "handle":"{{ menu.handle }}", "levels": "{{ menu.levels }}" }, "parent":[ {% assign parentResult = "" %} {% assign parentIndex = 1 %} {% assign currentMenu = linklists[menu.handle] %} {% for link in currentMenu.links %} {% assign parentObj = link | map: 'object' %} {% assign parentId = parentObj[0].id %} {% assign temp = '{"id":"' %} {% assign temp = temp | append: parentId %} {% assign temp = temp | append: '", "title":"' %} {% assign temp = temp | append: link.title %} {% assign temp = temp | append: '", "handle":"' %} {% assign temp = temp | append: link.handle %} {% assign temp = temp | append: '", "link_type": "' %} {% assign temp = temp | append: link.type %} {% assign temp = temp | append: '", "custom_index": "' %} {% assign temp = temp | append: parentIndex %} {% assign temp = temp | append: '"},' %} {% assign parentResult = parentResult | append: temp %} {% assign parentIndex = parentIndex | plus: 1 %} {% endfor %} {% if parentResult == "" %} {% else %} {% assign parentSize = parentResult | size | minus: 1 %} {{parentResult | slice: 0, parentSize}} {% endif %} ], "child":[ {% assign childResult = "" %} {% assign cParentIndex = 1 %} {% assign childIndex = parentIndex %} {% for link in currentMenu.links %} {% assign parentObj = link | map: 'object' %} {% assign parentId = parentObj[0].id %} {% for child in link.links %} {% assign childObj = child | map: 'object' %} {% assign temp = '{"id":"' %} {% assign temp = temp | append: childObj[0].id %} {% assign temp = temp | append: '", "title":"' %} {% assign temp = temp | append: child.title %} {% assign temp = temp | append: '", "handle":"' %} {% assign temp = temp | append: child.handle %} {% assign temp = temp | append: '", "link_type": "' %} {% assign temp = temp | append: child.type %} {% assign temp = temp | append: '", "parent_id": "' %} {% assign temp = temp | append: parentId %} {% assign temp = temp | append: '", "custom_index_parent": "' %} {% assign temp = temp | append: cParentIndex %} {% assign temp = temp | append: '", "custom_index": "' %} {% assign temp = temp | append: childIndex %} {% assign temp = temp | append: '"},' %} {% assign childResult = childResult | append: temp %} {% assign childIndex = childIndex | plus: 1 %} {% endfor %} {% assign cParentIndex = cParentIndex | plus: 1 %} {% endfor %} {% if childResult == "" %} {% else %} {% assign parentSize = childResult | size | minus: 1 %} {{childResult | slice: 0, parentSize}} {% endif %} ], {% assign sChildIndex = parentIndex %} "sub_child":[ {% assign subChildResult = "" %} {% for link in currentMenu.links %} {% for child in link.links %} {% assign childObj = child | map: 'object' %} {% assign childId = childObj[0].id %} {% for subChild in child.links %} {% assign subChildObj = subChild | map: 'object' %} {% assign temp = '{"id":"' %} {% assign temp = temp | append: subChildObj[0].id %} {% assign temp = temp | append: '", "title":"' %} {% assign temp = temp | append: subChild.title %} {% assign temp = temp | append: '", "handle":"' %} {% assign temp = temp | append: subChild.handle %} {% assign temp = temp | append: '", "link_type": "' %} {% assign temp = temp | append: subChild.type %} {% assign temp = temp | append: '", "parent_id": "' %} {% assign temp = temp | append: childId %} {% assign temp = temp | append: '", "custom_index_parent": "' %} {% assign temp = temp | append: sChildIndex %} {% assign temp = temp | append: '"},' %} {% assign subChildResult = subChildResult | append: temp %} {% endfor %} {% assign sChildIndex = sChildIndex | plus: 1 %} {% endfor %} {% endfor %} {% if subChildResult == "" %} {% else %} {% assign parentSize = subChildResult | size | minus: 1 %} {{subChildResult | slice: 0, parentSize}} {% endif %} ] } {% if forloop.last == false %},{% endif %} {% endfor %} ]