json4s/json4s — pull request #40 by theon (2013-04-17 22:52:11+00:00)
Title: Change remove() and removeField() to remove JValues, rather than setting them to JNothing

This pull request changes the current behaviour of remove() and removeField() setting `JValue`s and `JField`s to `JNothing` to actually removing them instead. Here is the reasoning behind the change:

# Fixing Inconsistent Diff Behaviour

Say you start with the following `JObject`:

{
"language": "Scala"
}

and you add the field `"author": "Martin"`, but then remove it, you should have a `JObject` identical to the original. If you render the two `JObject`s out they look the same, however if you run a diff, you get the following:

Diff(JNothing,JObject(List((author,JNothing))),JNothing)

The fact a remove has happened in the past shouldn't change the way diff works. This pull request makes diff work in the same way after a remove as if you were diffing two identical `JObject`s and you instead get

Diff(JNothing,JNothing,JNothing)

# Fixing Inconsistent XPath behaviour

This is similar to the diff problem. Say you start with the following `JObject`:

{
"language": "Scala"
"related": {}
}

If you run `jval \\ "language"` you get a `JString("Scala")`.

If you and you add a field `related.language` and then remove it, you should have a `JObject` identical to the original. However if you now run `jval \\ "language"` you get a `JObject(List(("language",JString("scala")), ("language",JNothing)))`

This pull request removes this inconsistent behaviour.

# noNulls now works as advertised

The `noNulls` method has the following comment in the code

/**
* Remove the [[org.json4s.JsonAST.JNothing]] and [[org.json4s.JsonAST.JNull]] from
* a [[org.json4s.JsonAST.JArray]] or [[org.json4s.JsonAST.JObject]]
*/

However this wasn't true. `noNulls` would actually turn any `JNull`s into `JNothing`s and wouldn't change `JNothing`s at all. This pull request fixes this.