Home » U++ Library support » U++ Core » XmlizeByJsonize() problem and proposed solution
XmlizeByJsonize() problem and proposed solution [message #36716] |
Thu, 28 June 2012 18:02 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
Using XmlizeByJsonize() when loading an empty String field I get an exception. See this:
template<> void Jsonize(JsonIO& io, String& var)
{
if(io.IsLoading()) {
const Value& v = io.Get();
if(IsString(v))
var = v;
else
throw JsonizeError("string expected");
}
else
io.Set(var);
}
If v is Null an error is thrown.
A simple solution could be to put:
template<> void Jsonize(JsonIO& io, String& var)
{
if(io.IsLoading()) {
const Value& v = io.Get();
if(IsNull(v)) // NEW
var = ""; // NEW
else if(IsString(v))
var = v;
else
throw JsonizeError("string expected");
}
else
io.Set(var);
}
Best regards
Iñaki
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 09:44:38 CEST 2024
Total time taken to generate the page: 0.02875 seconds
|