Hash when decoding JSON [ Mr. Rao ]
Posted: Wed Jul 19, 2017 9:52 pm
In a previous thread, you shared the following function:
Unfortunately the line hHash := &cStr creates an error with &.
I am building this whith FWH 17.06 plus Harbour and MSVC++ 2017
Do you have an alternative ?
The ultimate objective is this. I receive a JSON document. It is built as follows:
SECTION 1
SECTION 2
SECTION 3 // This is the data I want
Subsection 3A
DetailSections // There may be several of these
Details
Subsection 3B
Activity // There will be many of these
Details // Each of these may have multiple lines
I will be reading all lines in Section 3, in sequence, and will want to add each line to an array. Ultimately this will display a BROWSER display.
Currently, if I use hb_JSONdecode( file ) and put that in a browser, it shows me the 3 sections. Then there are [=>] marks for each subsection. I click on those and get a new browser. Within those I see the detail sections with the same symbol. I click on the value and it opens another browser to reveal the data.
So ... putting the values into a hash table would be helpful because then I should be able to pick up the values and add them to my displayable browser so I can see everything at once.
Again, this is not to find individual data, but actually a viewer to see all of the data
Tim
Code: Select all
function StrToHashArray( cStr )
local hHash, aHash
cStr := CharRepl( "[]", RangeRem( 1, 31, cStr ), "{}" )
do while '" :' $ cStr
StrTran( cStr, '" :', '":' )
enddo
cStr := StrTran( cStr, '":', '"=>' )
hHash := &cStr
aHash := HGetValueAt( hHash, 1 )
xbrowser aHash setup ( obrw:autofit(), oBrw:bRClicked := { |r,c,f,o| o:ToDbf( "download.dbf", nil, nil, .t. ) } )
return nil
I am building this whith FWH 17.06 plus Harbour and MSVC++ 2017
Do you have an alternative ?
The ultimate objective is this. I receive a JSON document. It is built as follows:
SECTION 1
SECTION 2
SECTION 3 // This is the data I want
Subsection 3A
DetailSections // There may be several of these
Details
Subsection 3B
Activity // There will be many of these
Details // Each of these may have multiple lines
I will be reading all lines in Section 3, in sequence, and will want to add each line to an array. Ultimately this will display a BROWSER display.
Currently, if I use hb_JSONdecode( file ) and put that in a browser, it shows me the 3 sections. Then there are [=>] marks for each subsection. I click on those and get a new browser. Within those I see the detail sections with the same symbol. I click on the value and it opens another browser to reveal the data.
So ... putting the values into a hash table would be helpful because then I should be able to pick up the values and add them to my displayable browser so I can see everything at once.
Again, this is not to find individual data, but actually a viewer to see all of the data
Tim