ring-clojure/ring — pull request #12 by mw10013 (2012-08-08 03:49:41+00:00)
Title: Extended nested keys syntax to allow indexing into nested vectors

A nested key that starts with '[' is passed to read-string and should return a vector. Numbers in that key vector are treated as indexes into nested vectors.

{"[:parents 0 :children 0 :grandchildren 0 :id]" "1"} => {:parents [{:children [{:grandchildren [{:id "1"}]}]}]}

This should have minimal impact on existing code since the existing parser takes "[parents]" and returns ["" "parents"], which seems to be a degenerate case.

{"[:parents 0 :children 0 :grandchildren 0 :id]" "1"
"[:parents 0 :children 0 :grandchildren 1 :id]" "2"
"[:parents 0 :children 1 :grandchildren 0 :id]" "3"
"[:parents 0 :children 0 :id]" "4"
"[:parents 0 :children 1 :id]" "5"
"[:parents 0 :id]" "6"}
=> {:parents
[{:id "6"
:children [{:id "4"
:grandchildren [{:id "1"} {:id "2"}]}
{:id "5"
:grandchildren [{:id "3"}]}]}]}