Hi,
I need to create a json collection to submit to a webserver and has used Capesoft jFilesCode to create the structure.
Below you can se the json structure, the data declaration and the code I have that works.
What I am missing is filling one element of the subqueue “parcels”.
I have a brainfart and cannot get any code to work.
Any ideas?
tia
/Poul
json:
{{
"product_code": "DAO_STS",
"service_codes": "EMAIL_NT,SMS_NT",
"sender": {{
"name": "A-fotograf",
"address1": "Tygestrupvej 17",
"zipcode": "4180",
"city": "Sorø",
"country_code": "DK",
},
"parcels": [
{{
"weight": 249
}
],
"reference": "Ordre nr.: 126126"
}
data embed:
element Group,Name('element'),PRE(elpre)
product_code STRING(255),Name('product_code| opt')
service_codes STRING(255),Name('service_codes| opt')
sender Group,Name('sender')
name STRING(255),Name('name')
address1 STRING(255),Name('address1')
zipcode STRING(255),Name('zipcode')
city STRING(255),Name('city')
country_code STRING(255),Name('country_code')
End
parcels &parcelsQueueType,Name('parcels| opt | queue')
reference STRING(255),Name('reference| opt')
End
parcelsQueueType Queue,Type,Name('parcels')
weight Real,Name('weight')
End
Json JSONClass
str StringTheory
code:
json.start()
json.SetTagCase(jf:CaseAsIs)
json.SetDontSaveBlanks(true)
json.SetDontSaveBlankArrays(true)
json.SetDontSaveBlankArrayValues(true)
json.SetDontSaveBlankGroups(true)
elpre:product_code = DAO_product_code
elpre:service_codes = DAO_service_codes
elpre:sender.name = DAO_afs_name
elpre:sender.address1 = DAO_afs_addr1
elpre:sender.zipcode = DAO_afs_zipcode
elpre:sender.city = DAO_afs_city
elpre:sender.country_code = 'DK'
elpre:reference = CLIP('Ordre nr.: ' & clip(FOTo:ID) )
!--> missing parcels.weight
json.Save(element,str) ! Save to a StringTheory object
json.DisposeGroup(element) !Optional Safe Tidy up of nested pointers