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 next message
koldo is currently offline  koldo
Messages: 3355
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
Re: XmlizeByJsonize() problem and proposed solution [message #36729 is a reply to message #36716] Fri, 29 June 2012 14:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Patch applied, thanks.
Re: XmlizeByJsonize() problem and proposed solution [message #36750 is a reply to message #36729] Sun, 01 July 2012 19:25 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Smile

Best regards
Iñaki
Previous Topic: LoadFromXML problem and solution
Next Topic: Jsonize of strings is corrupted
Goto Forum:
  


Current Time: Fri Mar 29 08:41:10 CET 2024

Total time taken to generate the page: 0.02110 seconds