%JSON.Adaptor
Hi.
Is it possible to set in XData mappings (or any other way) to serialize the property value as display value rather than value it self?
Regards,
Matjaž
Product version: IRIS 2021.2
Hi.
Is it possible to set in XData mappings (or any other way) to serialize the property value as display value rather than value it self?
Regards,
Matjaž
Hi @Matjaz Murko. Can you provide a code sample to help clarify your question?
Hi.
Class code:
{
Property Department As %String;
Property Ident As %String;
Index ProductId On (Department, Ident) [ IdKey, Unique ];
Property Name As %String;
Index Name On Name;
Property Type As %String(DISPLAYLIST = ",Sveže,Zmrznjeno,Dodelava", VALUELIST = ",FRE,FRO,FIN");
Property CUsInTU As %Integer;
Property NominalWeightCU As %Numeric;
Property WeightClassCU As %String;
Storage Default
{
<Data name="ProductDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>Type</Value>
</Value>
<Value name="4">
<Value>CUsInTU</Value>
</Value>
<Value name="5">
<Value>NominalWeightCU</Value>
</Value>
<Value name="6">
<Value>WeightClassCU</Value>
</Value>
</Data>
<DataLocation>^MasterData.ProductD</DataLocation>
<DefaultData>ProductDefaultData</DefaultData>
<IdLocation>^MasterData.ProductD</IdLocation>
<IndexLocation>^MasterData.ProductI</IndexLocation>
<StreamLocation>^MasterData.ProductS</StreamLocation>
<Type>%Storage.Persistent</Type>
}
XData RotorDataMapping
{
<Mapping xmlns="http://www.intersystems.com/jsonmapping">
<Property Name="Ident"/>
<Property Name="Name"/>
<Property Name="Type"/>
</Mapping>
}
I would like the property Type to be exported (%JSON.Export("RotorDataMapping") method) with display member rather than value member.
Regards,
Matjaž
Hiya,
Look at the %Library.String documentation.
You can use the JSONLISTPARAMETER
Property Type As %String(DISPLAYLIST = ",Sveže,Zmrznjeno,Dodelava", VALUELIST = ",FRE,FRO,FIN",JSONLISTPARAMETER=",Sveže,Zmrznjeno,Dodelava");
I have found that setting this parameter to the DISPLAYLIST parameter did not work, so I just put the same values in this parameter.
Hi.
It works with the parameter JSONLISTPARAMETER set to "DISPLAYLIST". But is it possible to set that parameter in XData mappings, so it can be use either way (DISPLAYLIST or VALUELIST)?
Regards,
Matjaž
It does not seem like the XData block parameters for the JSON mappings supports something like that.
I did the following to get a different output value on the JSON. It is not the prettiest solution.