   toJSON: (aOptions)->
     result = @toObject(aOptions)
     vType  = @$type
-    result = vType.valueToString result if vType.valueToString
+    if vType.valueToString
+      if result.hasOwnProperty 'value'
+        result.value = vType.valueToString result.value
+      else
+        result = vType.valueToString result
     result
   toJson: (aOptions)->
     result = @toJSON(aOptions)

      result = result.substring(i+1, result.length-1) if i >= 0
    else
      result = typeof aValue
    result
  constructor: (aValue, aType, aOptions)->
    if not (aType instanceof Type)

    @$type.createValue aValue, aOptions
  clone: (aOptions) ->
    @create @valueOf(), aOptions
  toString: -> String(@valueOf())
  valueOf: ->@value
  _toObject: (aOptions)->@valueOf()
  toObject: (aOptions)->
    if aOptions and aOptions.withType
      delete aOptions.withType
      result = @toObjectWithType(aOptions)
    else
      result = @_toObject(aOptions)
    result
  toObjectWithType: (aOptions)->
    result = @_toObject(aOptions)
    aOptions = {} unless aOptions
    aOptions.value = result
    @$type.toObject(aOptions)
