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 » Developing U++ » U++ Developers corner » Simple trick to have have bot JSON and XML for a class
Simple trick to have have bot JSON and XML for a class [message #49687] Tue, 03 April 2018 17:46 Go to next message
mirek is currently offline  mirek
Messages: 11713
Registered: November 2005
Ultimate Member
I needed class to support both JSON and XML. Initially, I have implemented both Xmlize and Jsonize but that is tedious.

Then I have found an obvious solution to the problem:

template <class T>
void MyClass::Ize(T& io)
{
	io
		("min", uMin)
		("max", uMax)
.....

}

void MyClass::Xmlize(XmlIO& xml) { Ize(xml); }

void MyClass::Jsonize(JsonIO& json) { Ize(json); }



Perhaps this will help somebody... Smile
Re: Simple trick to have have bot JSON and XML for a class [message #49688 is a reply to message #49687] Tue, 03 April 2018 18:09 Go to previous message
koldo is currently offline  koldo
Messages: 2922
Registered: August 2008
Veteran
So simple!!!

Shocked Shocked Shocked Shocked

We could deprecate XmlizeByJsonize()...


Best regards
IƱaki

[Updated on: Tue, 03 April 2018 18:09]

Report message to a moderator

Previous Topic: Upp as a shared library
Next Topic: Help!!! Building 32 bit apps on Ubuntu64
Goto Forum:
  


Current Time: Sat Feb 23 08:20:32 CET 2019

Total time taken to generate the page: 0.00867 seconds