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: 13975
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: 3355
Registered: August 2008
Senior 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: Thu Mar 28 23:19:08 CET 2024

Total time taken to generate the page: 0.01174 seconds