According to the documentation here, the function 'pds.convert()' is available for converting a PDS structure to a Lua table containing the same key/value pairs and sub-tables.
However, when I try to use pds.convert() on a "nested PDS" - that is, a PDS that contains more PDS's inside the structure - I get an error with no line number as follows:
Error - attempt to index a string value
Limitation
This is expected/unavoidable behavior due to a limitation in the Lua interpreter. The pds.convert() function can only convert a "flat" PDS, that is, a PDS which contains only key/value pairs, and cannot convert a PDS that contains nested/embedded PDS's within.
For example - here is a snippet of Lua code that creates two PDS's, an "Inner" and "Outer" PDS and puts a couple of key/value pairs inside each one, and then converts each PDS to a Lua table.
InnerPDS = pds.create()
OuterPDS = pds.create()pds.putString(InnerPDS, "InnerExampleKey1","InnerExampleValue1")
pds.putString(InnerPDS, "InnerExampleKey2","InnerExampleValue2")pds.putString (OuterPDS, "OuterExampleKey1", "OuterExampleValue1")
pds.putString (OuterPDS, "OuterExampleKey2", "OuterExampleValue2")InnerTable = pds.convert(InnerPDS)
OuterTable = pds.convert(OuterPDS)
This code runs successfully. However, if we use putPDS to embed the "Inner" PDS inside the "Outer" as follows:
pds.putPDS(OuterPDS, "NestedExampleKey", InnerPDS)
Then the conversion as follows will fail wtih the given error:
NestedTable = pds.convert(OuterPDS)