alertlogic/jesse — pull request #3 by alatnikov (2013-05-30 11:15:47+00:00)
Title: New feature: json path in the error accumulator callback

This pull request introduces new feature to jesse JSON validator using accumulator callback: error path that points to the exact error place in the original JSON.

The accumulator callback now takes three arguments, where the first one is the JSON path of the error place

```json
{
"collection": {
"title": "Developer books",
"books" : [
{
"title": "Thinking in Java",
"author": "Bruce Eckel"
},
{
"title": "Understanding Erlang",
"author": "Community"
}
]
}
}
```

JSON path notation follows the standard of XPath for XML. In general the following rules apply:

* Path element is the name of the object field. Look at the example above, if you want to reference the name of the whole collection, you simply have `"collection"` path.
* Object fields are separated with `.` (dot) symbol. A path to the collection title in the example above is `"collection.title"`.
* Elements of the array are numbered from 0. So in case you need to reference the second book's author, you have to provide the following path: `"collection.books[1].author"`

Here is an example error accumulator callback function, where `Path` is always an Erlang string, while other arguments didn't change:

```erlang
accumulator(Path, Error, List) ->
[[{path, Path}, {error, Error}] | List].
```