LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
PaulLotz

Support serialization of LabVIEW objects to interchangeable form of XML

Status: New

I suggest NI include a native feature to serialize LabVIEW objects in an interchangeable form.  (Alternatively, NI can at least provide enough access to allow a third party to develop such a framework.)

 

By "interchangeable" I mean in a manner that allows sharing object data between platforms (e.g., between LabVIEW and Java).  (Hence having "default data" without specifying the values of the default data is not allowed.)  Moreover, using a more common format (such as "Simple XML") is appropriate.

 

Of course, including the object version number is only meaningful within LabVIEW, but this is useful within LabVIEW thanks to the capability of LabVIEW objects to translate between versions.  (Note: I recognize the versioning can't avoid all possible issues, but in practice I think that is rarely a practical issue.)

 

I understand that for security reasons a developer may want to turn off the ability to serialize an object.  To support that, I envision a checkbox to allow serialization (default = True) in the class properties dialog.

 

I think XML is the best option for this for several reasons:

1) It is a common way to serialize objects in different environments.  This means that I can exchange serialized data with Java applications, for example.

2) It is readable, albeit not easily readable, by human beings.  (I actually don't want humans to read serialized data very often--and really never the operator, but it is good that they can on the rare occasion when they need to do so.)


Why I think NI should implement this:

1) This is relatively straightforward for NI to do since NI can already serialize a class to the current (noninterchangeable) LabVIEW XML format.

2) Having this capability could greatly expand the application space of LabVIEW, since it would make it orders of magnitude easier to interface with nonLabVIEW applications.  This is especially important in large systems, in which it may be advantageous to implement some system components in one environment and other components in another environment.  This is, I think, by far the most compelling reason to include this feature.

3) That there is a need for this seems obvious, given the number of lengthy discussions just on LAVA about this topic.

4) The current situation, in which each class must contain specific code for serialization, is patently inefficient and nonsensical.

5) In other major languages meaningful object serialization is a given, and LabVIEW should include (indeed, must include) this functionality to be competitive.


For the record, to serialize LabVIEW object data for communication within LabVIEW we use either the methods to flatten to string or to XML, and this works fine.  I realize it's not theoretically 100% fool-proof, because of potential issues across different object versions, but in practice we use version control, so that we build applications using the same versions of interface code (usually), and we only have one large system, so we can pretty easily control our deployed applications.   (I think that versioning an application could achieve the same.)  In practice, we've never experienced a version problem with this approach, and it avoids having to write any class-specific code (which, again, a developer should definitely not have to do) to support serialization.

12 Comments
Philmod
Member

Is it possible to user the JSON flattener out of the web service ui?

AristosQueue (NI)
NI Employee (retired)

I never saw this idea on the Exchange until today, but I've certainly been asked about something like it many times. Please see my ongoing work in this area here:

AQ Character Lineator (working draft version of serialization/deserialization)

https://decibel.ni.com/content/docs/DOC-24015

 

When I started building that library, I was working toward something like what this idea requests. Over time, as I researched what happens in other programming languages and the use cases of data serialization for objects, I realized that there was a much deeper and more fundamental problem to be solved. The current Character Lineator is 700+ VIs in size. That is large, but appears to completely cover all known data mutation/preservation/restoration/encryption/filtering requests when writing objects to a file/DB to be retrieved later or when streaming objects between a client and server whose versions may be different from each other. The library has been successfully used in two real-world applications that I know of... I would appreciate more users downloading it, trying it, and providing feedback to me. This is strictly an outside-of-my-official-job project, but it is one that I would like to see become a part of LabVIEW itself if the community can help me refine the design. Obviously, the number of VIs in this library is a significant issue ("how can data serialization dwarf most applications?!" is a common question I get -- you have to use the library a bit to see what drives that large VI count), but I figured if I got the whole system working, we could then better judge how it might be broken down into separate parts.