VCOM:Working with JSON: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
(Created page with "{{LocationMain|category=LocationVCOMSpecial|specific=}} <div class="rightmenu"> __TOC__ </div> == Enumerating Folder Contents == <code lang="cpp"> IJSONParserPtr jsonParser( ...")
(No difference)

Revision as of 20:34, 16 November 2018

.SDK|SDK ..SDK:Types|SDK Types ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Enumerating Folder Contents

IJSONParserPtr jsonParser( IID_JSONParser );

TJSONMap	jsonData;
VCOMError err = jsonParser->Extract( json, jsonData );
if ( VCOM_SUCCEEDED( err ) )
{
	if ( jsonData.find("hasData") != jsonData.end() )
	{
		bool hasData = jsonData["hasData"]->Bool( false );
		hasData = hasData; // -> true
	}

	TJSONArray arrColors = jsonData["colors"]->Array();
	TXString colorName = arrColors[1]->Map()["color"]->String();
	colorName = colorName; // -> "white"
}