News for hackers. Stuff that matters.
Re:JSONPath - XPath for JSON by cdumler on Monday January 21, 2013 @12:49PM (#5092634)
The project that I am working is document-oriented, meaning that the schema cannot be well controlled. We end up with a lot of code is very guarded code that looks something like this:

  if(((json.author || {}).lastPublish || {}).publishDate)) {
    do something
  }
It can be replaced with:

  if(jsonPath(json, "$.author.lastPublish .publishDate")) {
    do something
  }
Or better, get all book publish dates, regardless of number of books, if any even exist, and those that might have a missing publishDate:

  publishDates = jsonPath(json,"$.author.books[*].publishDate");

There are no comments on this comment yet.