views:

250

answers:

3

At work we have a testing tool that is used to send queries to a data source. The tool takes in input as XML files. The XML files were simple and easy to parse as long as the data structures we tried to represent were one layer deep. But now these data structures are more complex and representing them in XML is getting to be highly confusing. Any thoughts on what I can use to represent the data structures instead of XML ?

Example: Before,

class Foo { int userId; string name; string address; string eMail; }

Now,

class Foo { int userId, string name, vector loc, map attributes; }

class Location { Address addr; //class Address vector lcTime; //class LocatedTime Position ps; //class Position }

... and so on to have any number of nested structures.

I was tilting towards JSON but am open to any representation formats.

+2  A: 

YAML may be what you're looking for.

JesperE
+3  A: 

Have you looked at Protocol Buffers? Binary serialization which is pretty efficient in processing time and storage space. Currently "properly" supported in C++, Java and Python, with more implementations coming (from third parties - such as myself; I'm implementing a C# port).

Jon Skeet
A: 

You might consider using Lua (or another scripting language). You get a nice data structure syntax (roughly on par with JSON), with the full power of a programming language. Thus you have variables (you can build up your data structures piece by piece, symbolically declare recurring values, etc.), loops (test data is often repetitive), functions (think of them as macros for boilerplate constructs in your data).

Lua is a particularly attractive candidate for this sort of use because it's small (adds 100-200K to your program) and has a pretty elegant interface to and from C code.

Randy Hudson