Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » XmlizeByJsonize() problem and proposed solution
XmlizeByJsonize() problem and proposed solution [message #36716] Thu, 28 June 2012 18:02 Go to previous message
koldo is currently offline  koldo
Messages: 3358
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
 
Read Message
Read Message
Read Message
Previous Topic: LoadFromXML problem and solution
Next Topic: Jsonize of strings is corrupted
Goto Forum:
  


Current Time: Mon Apr 29 12:46:10 CEST 2024

Total time taken to generate the page: 0.04292 seconds