Factorization of some code.

Signed-off-by: François de Metz <francois@stormz.me>
More idiomatic ruby.

Signed-off-by: François de Metz <francois@stormz.me>
Use an array to create the json pointer.

Signed-off-by: François de Metz <francois@stormz.me>