v, err := tree.FindMap(data, "map") Ω(err).ShouldNot(HaveOccurred()) Ω(v).Should(Equal(map[string]interface{}{ "k": "v", "n": 1, })) n, err := tree.FindString(data, "map.k") Ω(err).ShouldNot(HaveOccurred()) Ω(n).Should(Equal("v")) }) }) Context("tree.FindArray()", func() { It("should fail if tree.Find() fails", func() { v, err := tree.FindArray(data, "nonexistent") Ω(err).Should(HaveOccurred()) Ω(v).Should(Equal([]interface{}{})) }) It("should fail if path is not an array", func() { v, err := tree.FindArray(data, "number") Ω(err).Should(HaveOccurred()) Ω(v).Should(Equal([]interface{}{})) }) It("should succeed if path exists and is an array", func() { v, err := tree.FindArray(data, "array") Ω(err).ShouldNot(HaveOccurred()) Ω(v).Should(Equal([]interface{}{ 1,
// Returns a []interface{}-typed value found in the JSON data // returned in the response, at `path` func (r *Response) ArrayVal(path string) ([]interface{}, error) { return tree.FindArray(r.Data, path) }