bjorg/jDoc — pull request #1 by adammck (2014-05-27 15:37:35+00:00)
Title: Allow null values in documents

Prior to this patch, the following doc throws an error when being queried:

```json
{ "name": "something", "id": null }
```

This is quite problematic, because many JSON documents contain nulls, and even querying unrelated keys causes the same error. The cause of the bug is that (for some reason) in JS, `typeof(null) === "object"`, but `null` doesn't have a length property. So the following line throws an error if `value` happens to be null:

```js
if(typeof value === 'object' && typeof value.length === 'number')
```

This patch fixes the bug by adding a null check. As indicated by the new test, The return value of `match('id').text()` is still null, which is a bit unusual, but doesn't cause an actual error.