See gist:

Pages

---
layout: none
---
[
  {%- for page in site.pages %}
    {
      "title":      {{- page.title | jsonify }},
      "url":        {{- page.url | jsonify }}
    }
    {% unless forloop.last %},{% endunless %}
  {% endfor -%}
]

Posts

---
layout: none
---
[
  {%- for post in site.posts %}
    {
      "id":         {{- post.id | jsonify -}},
      "title":      {{- post.title | jsonify }},
      "date":       {{- post.date | jsonify }},
      "url":        {{- post.url | jsonify }},
      "tags":       {{- post.tags | jsonify }},
      "categories": {{- post.categories | jsonify }}
    }
    {% unless forloop.last %},{% endunless %}
  {% endfor -%}
]