diff --git a/std/json.d b/std/json.d index 894a7b3c49a..b66328731e8 100644 --- a/std/json.d +++ b/std/json.d @@ -39,7 +39,7 @@ enum JSON_TYPE : byte /// Indicates the type of a $(D JSONValue). STRING, INTEGER, /// ditto - UINTEGER,/// integers > 2^63-1 + UINTEGER,/// ditto FLOAT, /// ditto OBJECT, /// ditto ARRAY, /// ditto @@ -248,17 +248,28 @@ struct JSONValue } } - + /** + * Constructor for $(D JSONValue). If $(D arg) is a $(D JSONValue) + * its value and type will be copied to the new $(D JSONValue). + * Note that this is a shallow copy: if type is $(D JSON_TYPE.OBJECT) + * or $(D JSON_TYPE.ARRAY) then only the reference to the data will + * be copied. + * Otherwise, $(D arg) must be implicitly convertible to one of the + * following types: $(D typeof(null)), $(D string), $(D ulong), + * $(D long), $(D real), an associative array $(D V[K]) for any $(D V) + * and $(D K) i.e. a JSON object, any array or $(D bool). The type will + * be set accordingly. + */ this(T)(T arg) if(!isStaticArray!T) { assign(arg); } - + /// Ditto this(T)(ref T arg) if(isStaticArray!T) { assignRef(arg); } - + /// Ditto this(T : JSONValue)(inout T arg) inout { store = arg.store; @@ -293,6 +304,7 @@ struct JSONValue return store.object[k]; } + /// Implements the foreach $(D opApply) interface for json arrays. int opApply(int delegate(size_t index, ref JSONValue) dg) { enforceEx!JSONException(type == JSON_TYPE.ARRAY, @@ -309,7 +321,7 @@ struct JSONValue return result; } - /// Implements foreach interface json objects. + /// Implements the foreach $(D opApply) interface for json objects. int opApply(int delegate(string key, ref JSONValue) dg) { enforceEx!JSONException(type == JSON_TYPE.OBJECT,