How to set JSON_TYPE in 2.0.65

Justin Whear justin at economicmodeling.com
Mon Mar 31 13:04:07 PDT 2014


On Mon, 31 Mar 2014 15:05:10 -0400, Matt Soucy wrote:

> I believe that this was simplified in recent releases, so one only needs
> to do the following:
> 
> JSONValue oJson;
> oJson.object["myEntry"] = "MyText";
> 
> (Untested but I believe this is how it's supposed to be now)

That's correct, the type field has been moved to a read-only property.  
JSONValue should derive the appropriate type via assignment:

JSONValue i = 2; // type == INTEGER
JSONValue s = "s"; // type == STRING
JSONValue a = [ JSONValue(1.0) ]; // type == ARRAY (of FLOAT)

Note that you can also use the constructor (calls opAssign internally).


More information about the Digitalmars-d-learn mailing list