Re: Create an empty json object with std.json

2016-01-22 Thread Borislav Kosharov via Digitalmars-d-learn
On Friday, 22 January 2016 at 11:53:11 UTC, Andrea Fontana wrote: If you declare a JSONValue like this: JSONValue json; then: assert(json.type() == JSON_TYPE.NULL); Documentation at https://dlang.org/phobos/std_json.html#.JSONValue.type.2 suggests not to change type but to assign a new valu

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 15:25:58 UTC, wobbles wrote: On Tuesday, 19 January 2016 at 14:07:50 UTC, Borislav Kosharov wrote: On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: [...] I want to use float time in a game where I call the update method passing the delta time

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: In general, using floating point values with time is an incredibly bad idea. It can certainly make sense when printing stuff out, but using it in calculations is just asking for trouble given all of the unnecessary imprecision

Re: core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
On Sunday, 17 January 2016 at 18:57:13 UTC, biozic wrote: On Sunday, 17 January 2016 at 14:43:26 UTC, Borislav Kosharov wrote: Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"seconds"

core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"seconds" returns a long and if the duration is less than 1 second I get 0. My question is whats the right way to do it. Because I saw t

How to split a string/array with multiple separators?

2015-12-16 Thread Borislav Kosharov via Digitalmars-d-learn
I want to split a string using multiple separators. In std.array the split function has a version where it takes a range as a separator, but it works differently than what I want. Say if I call it with " -> " it will search for the whole thing together. I want to pass split a list of separators

Re: How to check if JSONValue of type object has a key?

2015-10-08 Thread Borislav Kosharov via Digitalmars-d-learn
Thanks guys that was I was looking for!

How to check if JSONValue of type object has a key?

2015-10-06 Thread Borislav Kosharov via Digitalmars-d-learn
I'm using std.json for parsing json. I need to check if a specific string key is in JSONValue.object. The first thing I tried was: JSONValue root = parseJSON(text); if(root["key"].isNull == false) { //do stuff with root["key"] } But that code doesn't work, because calling root["key"] will