Home » Developing U++ » U++ Developers corner » ASSERT when using ValueMap
Re: ASSERT when using ValueMap [message #47683 is a reply to message #47651] |
Tue, 07 March 2017 00:43 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
NilaT wrote on Tue, 21 February 2017 16:23Hello everyone, I've got a nice little "soft crash" again, may you can help me?
It happens when I try to "Add" something to a Value Map.
So my code basically looks like this:
Params params = HandleParams(param1, param2); // Params is a struct which contains some Strings, some ints, and a Time Variable
ValueMap result;
result.Add("key1", RawToValue(params.someVar));
There must be something more to it. I have checked with
ValueMap result;
result.Add("key1", RawToValue(params.someVar));
and that works just fine.
Quote:
Oh and another thing I already fixed, but it also bothers me:
ValueMap map = rpc["params"]; // rpc = RpcData type
int x = ValueTo<int>(map["someKey"]);
will crash, because it says invalid value convertion, double --> int
Why the heck is map["someKey"] a double value, when it's int?
How do you know it is 'int' when reading JSON?
int/double/int64 (and sometimes bool) are used interchangeably. When reading JSON, double is used as "safe option" (because when it is number, it can always be double).
The safe and natural way how to write that is
will convert the Value to 'int' when possible.
Mirek
|
|
|
|
|
ASSERT when using ValueMap
By: NilaT on Tue, 21 February 2017 16:23
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Wed, 22 February 2017 11:56
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Mon, 27 February 2017 16:17
|
|
|
Re: ASSERT when using ValueMap
|
|
|
Re: ASSERT when using ValueMap
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Fri, 03 March 2017 09:29
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 00:43
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 00:58
|
|
|
Re: ASSERT when using ValueMap
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 11:29
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 11:42
|
|
|
Re: ASSERT when using ValueMap
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 13:47
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Tue, 07 March 2017 14:54
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 15:00
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Tue, 07 March 2017 11:54
|
|
|
Re: ASSERT when using ValueMap
By: mirek on Tue, 07 March 2017 12:10
|
|
|
Re: ASSERT when using ValueMap
By: NilaT on Tue, 07 March 2017 15:49
|
Goto Forum:
Current Time: Sat May 11 20:10:14 CEST 2024
Total time taken to generate the page: 0.03173 seconds
|