We can view a structured Json using either FW_MemoEdit() or XBrowse this way.
Code: Select all | Expand
#include "fivewin.ch"
function Main()
local cJson, hHash, oTree
local cTitle := "JSON VIEW"
TEXT INTO cJson
{"numRows":1182,"numPages":591,"pageNumber":0,"startIndex":0,"endIndex":2,"totalValue":"10819097.2000","totalPurchaseValue":"0.0000",
"totalMargin":"10819097.2000","totalQuantity":306361,"totalPhysicalQuantity":54,"totalMinimumQuantity":0,"lowestPrice":"0.0000",
"highestPrice":"365.0300","data":[{"uprid":"543","productId":543,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],
"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWU03W","hsCode":null,
"name":"#Hoodie","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/sweaters\/sweaters-met-kap\/hoodie","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"0000-00-00 00:00:00","lastModified":"2020-09-11 16:41:37","descriptions":{"description":"Uniseks <br> French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcwu03w.jpg","bcwu03w_black-pure.jpg","bcwu03w_candy-pink.jpg","bcwu03w_desert.jpg","bcwu03w_elephant-grey.jpg","bcwu03w_forest-green.jpg","bcwu03w_grey-fog.jpg","bcwu03w_hawaiian-blue.jpg","bcwu03w_heather-asphalt.jpg","bcwu03w_heather-dark-green.jpg","bcwu03w_heather-grey.jpg","bcwu03w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888963","name":"Sweaters met kap","categoryIds":"888963","cPath":"73_888904_888963"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}},{"uprid":"561","productId":561,"stockId":-1,"referenceId":0,"isBundle":0,"bundledProducts":[],"status":1,"quantity":"400","maximumQuantity":null,"ean":"","sku":"","model":"BCWW04W","hsCode":null,"name":"#Hoodie Sweat \/Women","price":"13.4280","taxClassId":"3","taxRate":"21.0000","isPhysical":"1","isDigital":"0","isQuotation":"1","url":"promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","urlAbs":"https:\/\/www.maveco-webshop.be\/promotiekleding\/dames\/dames-sweaters--fleece\/hoodie-sweat-women","attributesString":"","backOrder":0,"onHome":0,"layover":1,"configurationAllowCheckout":1,"configurationStockCheck":0,"attributes":[],"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","addonInstagramEnabled":"0","addonInstagram":"0","addonOcsEnabled":"0","dateAdded":"2020-09-11 16:41:47","lastModified":"2020-09-11 16:41:47","descriptions":{"description":"French Terry <br> Lange mouwen <br> Hooded <br> Regular fit <br> Voorgekrompen ringgesponnen katoen <br> Zijnaden <br> Gemakkelijke branding: geen B&C label <br> Binnenkant Single Jersey halfmoon in rug <br> Ongeborstelde stof <br> Sterke stof <br> Zacht handgevoel <br> Glad en gelijkmatig oppervlak <br> In zijnaad: Zacht satijnlabel","extra":"","intro":" 280 g\/m"},"images":["bcww04w.jpg","bcww04w_black-pure.jpg","bcww04w_candy-pink.jpg","bcww04w_desert.jpg","bcww04w_elephant-grey.jpg","bcww04w_forest-green.jpg","bcww04w_grey-fog.jpg","bcww04w_hawaiian-blue.jpg","bcww04w_heather-asphalt.jpg","bcww04w_heather-dark-green.jpg","bcww04w_heather-grey.jpg","bcww04w_heather-mid-grey.jpg"],"image_alt":["","","","","","","","","","","",""],"discounts":{"name":"0","groupDiscount":"0.00","groupDiscountCategory":"0.00","groupDiscountProduct":"0.00"},"category":{"id":"888955","name":"Dames Sweaters & Fleece","categoryIds":"888955","cPath":"73_888940_888955"},"quantities":{"quantity":"400","physicalQuantity":"0","minimumQuantity":"0","maximumQuantity":null,"externalQuantity":"0","quantityStep":"1","trackQuantity":"1"},"prices":{"basePrice":"14.9200","normalPrice":"14.9200","price":"13.4280","specialPrice":"13.4280","purchasePrice":"0.0000"},"manufacturer":{"id":46,"name":"B&C","image":"bc.jpg-preview72.jpg"},"dimensions":{"type":"0","width":0,"height":0,"area":0,"weight":0},"reviews":{"count":0,"avg":0},"resources":[],"addons":{"multicatalog":{"enabled":false},"layover":{"enabled":true}}}]}
ENDTEXT
// using FW_MEMOEDIT
#if FW_VersionNo >= 23040
JsonView( cJson, cTitle ) // cJson can be text or file name
#else
FW_MemoEdit( hb_JsonEncode( hb_JsonDecode( cJson ), .t. ), cTitle )
#endif
// Using XBrowse
XBROWSER HashTree( hb_JsonDecode( cJson ), 0 ) TITLE "JSON BROWSE" ;
SETUP ( ;
oBrw:cHeaders := { "ITEM", "VALUE" }, ;
oBrw:aCols[ 2 ]:bStrData := { |x,o| If( o:oBrw:oTreeItem:lOpened,"",o:Value ) } )
return nil
// This is a function from XBrowse.
// Latest verion is included here for the benefit of older FWH versions
//
static function HashTree( hHash, nLevel, cParent )
local oTree
local n, uVal, oItem
TREE oTree
if ValType( hHash ) == "H"
for n := 1 to Len( hHash )
TREEITEM oItem PROMPT hb_hKeyAt( hHash, n ) CARGO { uVal := hb_hValueAt( hHash, n ) }
if !Empty( uVal )
if ValType( uVal ) == "H"
HashTree( uVal )
elseif ValType( uVal ) == "A"
HashTree( uVal, , oItem:cPrompt )
endif
endif
next
elseif ValType( hHash ) == "A"
DEFAULT cParent := "Array"
cParent += "[ "
for n := 1 to Len( hHash )
TREEITEM oItem PROMPT cParent + cValToChar( n ) + " ]" ;
CARGO { uVal := hHash[ n ] }
if !Empty( uVal )
if ValType( uVal ) == "H"
HashTree( uVal )
elseif ValType( uVal ) == "A"
HashTree( uVal, , oItem:cPrompt )
endif
endif
next
endif
ENDTREE
if ValType( nLevel ) == "N"
if nLevel > 0
oTree:Expand( nLevel )
else
oTree:OpenAll()
endif
endif
return oTree