Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: Is there serializer/deserializer for object type Any

$
0
0

Hi,

 

First, a couple of remarks.

  • SOAP API is deprecated and will be removed in upcoming vRO 7.0, so you may want to look into REST API
  • Strictly speaking, there are no objects of 'any' type. Eg. when a workflow is defined as having an input parameter of type any, when you call it it actually pass an object of some concrete type.

 

Now to your question. There is a class ch.dunes.model.type.AnyConvertor (in o11n-model) that could be useful. The following sample code should work

 

AnyConvertor conv = new AnyConvertor();
String value = "Array##{#Properties##[#attr2#=#string#drugi#+#attr1#=#string#prvi#+#arrAttr1#=#Array##{#Properties##[#drugi#=#string#1-2#+#treci#=#string#1-3#+#prvi#=#string#1-1#]##;#Properties##[#drugi#=#string#2-2#+#treci#=#string#2-3#+#prvi#=#string#2-1#]##}##]##}#";
try {    // convert string representation to object    Object obj = conv.toObject(value, null, ConvertorContext.SERVER_CONTEXT);    if (obj != null) {      StringBuffer buffer = new StringBuffer();      // convert object back to string representation      conv.toString(buffer, obj, ConvertorContext.SERVER_CONTEXT);      String s = buffer.toString();    }
} catch (ConvertorException e) {  e.printStackTrace();
}

 

Not sure which class you are using for JSON objects so you may need to write some simple adaptor code to provide mapping between your JSON objects and the objects returned by AnyConvertor.


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>