<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Am I a noob or this is the way the JSONDOM Parser it should work? in Archicad Python API</title>
    <link>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276257#M42</link>
    <description>&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;using namespace HTTP::Client;
	using namespace HTTP::MessageHeader;
	using namespace GS::IBinaryChannelUtilities;

	JSON::JDOMParser jParser;
	
	IO::URI::URI connectionUrl("http://geoportal.ancpi.ro/geoprocessing/rest/services/LOOKUP/UATLookup/GPServer/FastSelect/execute?f=json&amp;amp;Expression=WORKSPACEID=10");
	
	ClientConnection clientConnection(connectionUrl);
	clientConnection.Connect();

	Request getRequest(Method::Get, connectionUrl);

	getRequest.GetRequestHeaderFieldCollection().Add(HeaderFieldName::UserAgent,
		"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36");
	clientConnection.Send(getRequest);

	Response response;

	//Parse the top object of the JSON File
	JSON::ValueRef parsed = jParser.Parse(clientConnection.BeginReceive(response));
	JSON::ObjectValueRef obj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);
	
	//Get the array named results into arrValRef
	GS::UniString atName = "results";
	JSON::ArrayValueRef arrValRef;
	obj-&amp;gt;GetMandatoryMember(atName, arrValRef);

	//Get the first and single item of the array
	JSON::ValueRef first = arrValRef-&amp;gt;Get(0);
	//Parse it again into an ObjectValueRef
	JSON::ObjectValueRef resultsObj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(first);
	//debug so I can be sure what it is
	DBPrintf("Size of reultsObj is %u\n", resultsObj-&amp;gt;GetSize());
	

	DBPrintf("Type of resultsObj[2] is %s\n", resultsObj-&amp;gt;GetName(2).ToCStr().Get());

	//Get the third element from results array : "value" this is an object
	JSON::ValueRef valuesRef = resultsObj-&amp;gt;Get(2);
	//Parse it into a ObjectvalueRef
	JSON::ObjectValueRef valuesObj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(valuesRef);

	//Get the array I wanted finally, the features array containing information about cities
	JSON::ArrayValueRef fieldsArray;
	valuesObj-&amp;gt;GetMandatoryMember("features", fieldsArray);

	//Iterate trough the "features" array
	for (unsigned int i = 0; i &amp;lt;= fieldsArray-&amp;gt;GetSize(); i++) {

		//Debug to be sure that the correct one is selected
		DBPrintf("Working %u times\n", i);
	}
	

	/*GS::IChannelX channel(clientConnection.BeginReceive(response), GS::GetNetworkByteOrderIProtocolX());

	DBPrintf("HTTP %u\n", response.GetStatusCode());
	DBPrintf("Received data: \n");

	GS::UniString body = ReadUniStringAsUTF8(channel, StringSerializationType::NotTerminated);
	GS::Array&amp;lt;GS::UniString&amp;gt; lines;
	body.Split("\n", GS::UniString::KeepEmptyParts, &amp;amp;lines);
	for (GS::UniString&amp;amp; line : lines) {
		DBPrintf("%s\n", line.ToCStr(0, MaxUSize, GSCharCode::CC_Legacy).Get());
	}
	DBPrintf("Read %u characters, %u lines \n", body.GetLength(), lines.GetSize());*/
	   	 
	clientConnection.FinishReceive();
	clientConnection.Close(false);
&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Jun 2021 13:35:34 GMT</pubDate>
    <dc:creator>Mihalcea Bogdan</dc:creator>
    <dc:date>2021-06-17T13:35:34Z</dc:date>
    <item>
      <title>JSON Parser ObjectValueRef and ObjectValue meaning?</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276256#M41</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;A href="http://geoportal.ancpi.ro/geoprocessing/rest/services/LOOKUP/UATLookup/GPServer/FastSelect/execute?f=json&amp;amp;Expression=WORKSPACEID=10" target="_blank" rel="noopener"&gt;The GET request I am trying to parse&lt;/A&gt;&lt;BR /&gt;Hi! I am trying to parse and traverse a JSON file from the link above.&lt;BR /&gt;After I successfully make the connection it is parsed and ready to do whatever I want with the Object.&lt;BR /&gt;I just don't know what to do... what kind of object is this? Is there any in depth documentation about this parser?&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;JSON::JDOMParser jParser;
JSON::ValueRef parsed = jParser.Parse(clientConnection.BeginReceive(response));
	JSON::ObjectValueRef obj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);
	
	GS::UIndex idx = 0;
	GS::UniString name = obj-&amp;gt;GetName(idx);//This gets me the value "results" as it should
	bool isObj = obj-&amp;gt;IsObject();//true
	
	JSON::ValueRef resultsRef = obj-&amp;gt;Get("results");//If I DBPrintf this it ouputs "Array"
&lt;/PRE&gt;
I don't fully understand how to "navigate" or "read" the parsed Object. I didn't found any documentation about the JSON Parser below
&lt;PRE&gt;JSON::JDOMParser&lt;/PRE&gt;
Can you please help me with some ideas how to traverse this JSON object?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:34:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276256#M41</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-09-14T07:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Am I a noob or this is the way the JSONDOM Parser it should work?</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276257#M42</link>
      <description>&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;using namespace HTTP::Client;
	using namespace HTTP::MessageHeader;
	using namespace GS::IBinaryChannelUtilities;

	JSON::JDOMParser jParser;
	
	IO::URI::URI connectionUrl("http://geoportal.ancpi.ro/geoprocessing/rest/services/LOOKUP/UATLookup/GPServer/FastSelect/execute?f=json&amp;amp;Expression=WORKSPACEID=10");
	
	ClientConnection clientConnection(connectionUrl);
	clientConnection.Connect();

	Request getRequest(Method::Get, connectionUrl);

	getRequest.GetRequestHeaderFieldCollection().Add(HeaderFieldName::UserAgent,
		"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36");
	clientConnection.Send(getRequest);

	Response response;

	//Parse the top object of the JSON File
	JSON::ValueRef parsed = jParser.Parse(clientConnection.BeginReceive(response));
	JSON::ObjectValueRef obj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(parsed);
	
	//Get the array named results into arrValRef
	GS::UniString atName = "results";
	JSON::ArrayValueRef arrValRef;
	obj-&amp;gt;GetMandatoryMember(atName, arrValRef);

	//Get the first and single item of the array
	JSON::ValueRef first = arrValRef-&amp;gt;Get(0);
	//Parse it again into an ObjectValueRef
	JSON::ObjectValueRef resultsObj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(first);
	//debug so I can be sure what it is
	DBPrintf("Size of reultsObj is %u\n", resultsObj-&amp;gt;GetSize());
	

	DBPrintf("Type of resultsObj[2] is %s\n", resultsObj-&amp;gt;GetName(2).ToCStr().Get());

	//Get the third element from results array : "value" this is an object
	JSON::ValueRef valuesRef = resultsObj-&amp;gt;Get(2);
	//Parse it into a ObjectvalueRef
	JSON::ObjectValueRef valuesObj = GS::DynamicCast&amp;lt;JSON::ObjectValue&amp;gt;(valuesRef);

	//Get the array I wanted finally, the features array containing information about cities
	JSON::ArrayValueRef fieldsArray;
	valuesObj-&amp;gt;GetMandatoryMember("features", fieldsArray);

	//Iterate trough the "features" array
	for (unsigned int i = 0; i &amp;lt;= fieldsArray-&amp;gt;GetSize(); i++) {

		//Debug to be sure that the correct one is selected
		DBPrintf("Working %u times\n", i);
	}
	

	/*GS::IChannelX channel(clientConnection.BeginReceive(response), GS::GetNetworkByteOrderIProtocolX());

	DBPrintf("HTTP %u\n", response.GetStatusCode());
	DBPrintf("Received data: \n");

	GS::UniString body = ReadUniStringAsUTF8(channel, StringSerializationType::NotTerminated);
	GS::Array&amp;lt;GS::UniString&amp;gt; lines;
	body.Split("\n", GS::UniString::KeepEmptyParts, &amp;amp;lines);
	for (GS::UniString&amp;amp; line : lines) {
		DBPrintf("%s\n", line.ToCStr(0, MaxUSize, GSCharCode::CC_Legacy).Get());
	}
	DBPrintf("Read %u characters, %u lines \n", body.GetLength(), lines.GetSize());*/
	   	 
	clientConnection.FinishReceive();
	clientConnection.Close(false);
&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jun 2021 13:35:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276257#M42</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-06-17T13:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: I think that the Parser is not working correctly.</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276258#M43</link>
      <description>All of my entries should have been objects (79 objects)  &lt;BR /&gt;
The objects structure is like this:  
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;"attributes": {
              "OID": 2,
              "ADMINISTRATIVEUNITID": 1213,
              "UAT": "Aiud"
            }
&lt;/PRE&gt; The JDOMParser gave me some inconsistent results as shown bellow.&lt;BR /&gt;

&lt;PRE&gt;Type of fieldsArray[0] is: Array
Type of fieldsArray[1] is: String
Type of fieldsArray[2] is: Unknown
Type of fieldsArray[3] is: Bool
Type of fieldsArray[4] is: Unknown
Type of fieldsArray[5] is: Unknown
Type of fieldsArray[6] is: String
Type of fieldsArray[7] is: Unknown
Type of fieldsArray[8] is: Unknown
Type of fieldsArray[9] is: Unknown
Type of fieldsArray[10] is: Null
Type of fieldsArray[11] is: Unknown
Type of fieldsArray[12] is: Bool
Type of fieldsArray[13] is: Unknown
Type of fieldsArray[14] is: Unknown
Type of fieldsArray[15] is: Null
Type of fieldsArray[16] is: Unknown
Type of fieldsArray[17] is: Unknown
Type of fieldsArray[18] is: Object
Type of fieldsArray[19] is: Array
Type of fieldsArray[20] is: Unknown
Type of fieldsArray[21] is: Null
Type of fieldsArray[22] is: Object
Type of fieldsArray[23] is: Unknown
Type of fieldsArray[24] is: Bool
Type of fieldsArray[25] is: Unknown
Type of fieldsArray[26] is: Unknown
Type of fieldsArray[27] is: Bool
Type of fieldsArray[28] is: Unknown
Type of fieldsArray[29] is: Unknown
Type of fieldsArray[30] is: Bool
Type of fieldsArray[31] is: Unknown
Type of fieldsArray[32] is: Unknown
Type of fieldsArray[33] is: Bool
Type of fieldsArray[34] is: Unknown
Type of fieldsArray[35] is: Unknown
Type of fieldsArray[36] is: Bool
Type of fieldsArray[37] is: Unknown
Type of fieldsArray[38] is: Unknown
Type of fieldsArray[39] is: Null
Type of fieldsArray[40] is: Unknown
Type of fieldsArray[41] is: Unknown
Type of fieldsArray[42] is: Object
Type of fieldsArray[43] is: Unknown
Type of fieldsArray[44] is: Unknown
Type of fieldsArray[45] is: Null
Type of fieldsArray[46] is: Null
Type of fieldsArray[47] is: Unknown
Type of fieldsArray[48] is: Bool
Type of fieldsArray[49] is: Unknown
Type of fieldsArray[50] is: Unknown
Type of fieldsArray[51] is: Unknown
Type of fieldsArray[52] is: Unknown
Type of fieldsArray[53] is: Unknown
Type of fieldsArray[54] is: Bool
Type of fieldsArray[55] is: Array
Type of fieldsArray[56] is: Unknown
Type of fieldsArray[57] is: Bool
Type of fieldsArray[58] is: Object
Type of fieldsArray[59] is: Unknown
Type of fieldsArray[60] is: Unknown
Type of fieldsArray[61] is: Unknown
Type of fieldsArray[62] is: Unknown
Type of fieldsArray[63] is: Unknown
Type of fieldsArray[64] is: Unknown
Type of fieldsArray[65] is: Unknown
Type of fieldsArray[66] is: Object
Type of fieldsArray[67] is: Unknown
Type of fieldsArray[68] is: Unknown
Type of fieldsArray[69] is: Unknown
Type of fieldsArray[70] is: Unknown
Type of fieldsArray[71] is: Unknown
Type of fieldsArray[72] is: String
Type of fieldsArray[73] is: Unknown
Type of fieldsArray[74] is: Unknown
Type of fieldsArray[75] is: Unknown
Type of fieldsArray[76] is: Unknown
Type of fieldsArray[77] is: Unknown
Type of fieldsArray[78] is: Number&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jun 2021 13:50:11 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276258#M43</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-06-17T13:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: JSON Parser ObjectValueRef and ObjectValue meaning?</title>
      <link>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276259#M44</link>
      <description>I found an interesting folder ... I think I solved my problem:&lt;BR /&gt;
&lt;B&gt;C:\Program Files\GRAPHISOFT\API Development Kit 24.3009\Support\Modules\RapidJSON&lt;/B&gt;&lt;BR /&gt;
I will try to make it run now on other PC.</description>
      <pubDate>Thu, 17 Jun 2021 14:28:00 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-Python-API/JSON-Parser-ObjectValueRef-and-ObjectValue-meaning/m-p/276259#M44</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-06-17T14:28:00Z</dc:date>
    </item>
  </channel>
</rss>

