Good day,
I proceeded to get Capesoft Jfiles since xFiles has been working amazingly for me.
I just cannot seem to find away for it to process my file. I do know that I am doing something wrong. Has anybody done this within ABC that I could and discuss this with to see where I am going wrong?
What specifically are you trying to? Describe the steps involved with “processing” your file.
Thanks.
So here’s an example:
The JSON
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": [
"GML",
"XML"
]
},
"GlossSee": "markup"
}
}
}
}
}
To LOAD the JSON:
glossary Group,Name('glossary')
title STRING(255),Name('title')
GlossDiv Group,Name('GlossDiv')
title STRING(255),Name('title')
GlossList Group,Name('GlossList')
GlossEntry Group,Name('GlossEntry')
ID STRING(255),Name('ID')
SortAs STRING(255),Name('SortAs')
GlossTerm STRING(255),Name('GlossTerm')
Acronym STRING(255),Name('Acronym')
Abbrev STRING(255),Name('Abbrev')
GlossDef Group,Name('GlossDef')
para STRING(255),Name('para')
GlossSeeAlso STRING(255),Dim(10),Name('GlossSeeAlso')
End
GlossSee STRING(255),Name('GlossSee')
End
End
End
End
json jsonClass
CODE
!-- Load From StringTheory object into Structure---
json.start()
json.SetTagCase(jf:CaseAsIs)
json.Load(glossary,SomeLoadString,'glossary') ! Load From a StringTheory object
To SAVE the JSON:
!-- Save From Structure into StringTheory object ---
json.start()
json.SetTagCase(jf:CaseAsIs)
json.Save(glossary,SomeSaveString,'glossary') ! Save to a StringTheory object
Hi ,
Thank you.
Here are my steps
I have added the Global extension to my application.
I then create JSON object and my queue
json JSONClass
StoresQ QUEUE
GroupId STRING(20),name(‘GroupID’)
GroupName STRING(50),name(‘GroupName’)
Node STRING(50),name(‘Node’)
Descr STRING(255),name(‘Descr’)
END
I then add the following to a button to process
json.Load(MabiloStoresQ, ‘c:\JSON\adriaan.json’, ‘data’)
Message(Records(MabiloStoresQ))
But I keep getting 0 records.
Blockquote
Hi
I have also tried the following and might be using it
element Group,Name(‘element’)
totalRecords Real,Name(‘totalRecords| opt’)
success Byte,Name(‘success| opt | boolean’)
data_ &dataQueueType,Name(‘data| opt | queue’)
End
dataQueueType Queue,Type,Name(‘data’)
GroupId Real,Name(‘GroupId’)
GroupName STRING(255),Name(‘GroupName’)
Node STRING(255),Name(‘Node’)
Descr STRING(255),Name(‘Descr’)
End
Json Class(jsonClass)
NewPointer Procedure(String pColumnName),Derived
End
CODE
!-- Load From StringTheory object into Structure—
json.start()
json.SetTagCase(jf:CaseAsIs)
json.Load(element,SomeLoadString) ! Load From a StringTheory object
json.DisposeGroup(element) !Optional Safe Tidy up of nested pointers
!--------------------------------------------------------------------------------
!-- Used by Load-Into-Structure
!--------------------------------------------------------------------------------
json.NewPointer Procedure(String pColumnName)
! note that pColumnName is the json tag name, not the label. case sensitive.
Code
Case pColumnName
Of ‘data’
element.data_ &= NEW dataQueueType
End
The second parameter in json.Load and json.Save references a StringTheory object.
So if you declare StringTheory like:
st StringTheory
Your json…Load would be something like:
json.Load(MabiloStoresQ, st, ‘boundary’) ! boundary is optional
json.Save:
json.Save('MabiloStoresQ, st , ‘boundary’)
Do you have an example of the JSON itself that you can share?
Here’s some code for you based on your JSON:
Your Clarion structure:
element Group,Name('element')
totalRecords Real,Name('totalRecords| opt')
success Byte,Name('success| opt | boolean')
data_ &dataQueueType,Name('data| opt | queue')
End
dataQueueType Queue,Type,Name('data')
GroupId Real,Name('GroupId')
GroupName STRING(255),Name('GroupName')
Node STRING(255),Name('Node')
Descr STRING(255),Name('Descr')
End
Json Class(jsonClass)
NewPointer Procedure(String pColumnName),Derived
End
!-- Load From StringTheory object into Structure---
json.start()
json.SetTagCase(jf:CaseAsIs)
json.Load(element,SomeLoadString) ! Load From a StringTheory object
json.DisposeGroup(element) !Optional Safe Tidy up of nested pointers
!--------------------------------------------------------------------------------
!-- Used by Load-Into-Structure
!--------------------------------------------------------------------------------
json.NewPointer Procedure(String pColumnName)
! note that pColumnName is the json tag name, not the label. case sensitive.
Code
Case pColumnName
Of 'data'
element.data_ &= NEW dataQueueType
End
!-- Save From Structure into StringTheory object ---
json.start()
json.SetTagCase(jf:CaseAsIs)
json.SetDontSaveBlanks(true)
json.SetDontSaveBlankArrays(true)
json.SetDontSaveBlankArrayValues(true)
json.SetDontSaveBlankGroups(true)
json.Save(element,SomeSaveString) ! Save to a StringTheory object
json.DisposeGroup(element) !Optional Safe Tidy up of nested pointers
1 Like
Thank you very much. I do appreciate it. I am having a better understanding now.