I did some research... Relationship properties with cardinality one or parent are not included by default in JSON serialization. If property is included with parameter %JSONINCLUDE is not enough, because serialization causes infinitive recursion. XData Mapping or %JSONINCLUDE="NONE" in related class should be used to avoid infinitive recursion.

Regards,
Matjaž

Hi.

In this part of the code:

Set Line = File.Read(1000)
While (File.Read(1000)'=""{ S mystring=mystring_File.Read(1000)

you are reading first 1000 chars which are not included in mystring and again in each loop checking the while condition you are reading 1000 chars and this chars are not included in mystring.

It should be:

//Set Line = File.Read(1000)
Set mystring = ""
While ('File.AtEnd{ S mystring=mystring_File.Read(1000) }

Regards,
Matjaž

Hi.

Set request=##class(%Net.HttpRequest).%New()
Set request.Server="something.com"
Set request.Port="some_port"
Set request.Username="some_username"
Set request.Password="some_password"

Set status=request.Get("some_url")
Do request.HttpResponse.Data.Rewind()
Set jsonString=request.HttpResponse.Data.Read(request.HttpResponse.Data.Size,.sc)

Set jsonObject={}.%FromJSON(jsonString)
Write jsonObject."some_property"
...

Something like that...

Regards,
Matjaž

Hi.

Class code:

Class MasterData.Product Extends (%Persistent, %JSON.Adaptor)
{
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ž