Start preparing for GraphSON.

Migrated JSON serialization code from Gremlin Server down to gremlin-core.