YAML, numeric keys in LinkedHashMap structure

I banged my head to the wall for a day, trying to find out the most
convenient way to read YAML files.
In short: Working with SnakeYAML, I get a structure, from where I can
examine the structKeyList, but can’t access any of the keys.

Example:

file: graphicIDs.yaml

10:
description: Moon
graphicFile: res:/dx9/model/worldobject/planet/moon.red
38:
description: Caldari Frigate Bantam
graphicFile: res:/dx9/model/ship/caldari/Frigate/CF1/CF1_T1.red
sofFactionName: caldaribase
sofHullName: cf1_t1
sofRaceName: caldari

code:

yamlPath = 'c:/databases/'; yamlGraphicIDs = parseYaml(yamlPath & 'graphicIDs.yaml');

function parseYaml(file)
{
Yaml =
createObject(‘java’,‘org.yaml.snakeyaml.Yaml’,‘c:/lucee/lib/snakeyaml-1.15.jar’);
yamlFileData = FileRead(arguments.file);
return Yaml.load(yamlFileData);
}

Now, everything seems to work nicely… #structKeyList(yamlGraphicIDs)#
lists the keys.

But then I hit the brick wall. structKeyExists function does not find any
of the keys. Neither does any bracket notation of the structure. CFDUMP
shows nothing.

Looking at getMetaData() of the returned structure shows it’s a
LinkedHashMap. A normal Lucee structure is a type of StructImpl. Now, I’m
not much of a Java person, so all this is a bit cryptic to me.

I do some Google-fu, and luckily find an old ColdFusion ORM related
solution:
Let’s javacast. #yamlGraphicIds.get(javacast(“int”,10)).description# works
nicely!

Question: Would there be a way to convert the LinkedHashMap structure to a
format that can be cfdumped and manipulated normally?
If I create a new structure with StructNew(), I surely can address numeric
key values without problems, because the structure is of a different type,
native to Lucee.

Cheers,
-Ari

Sorry I replied somewhere else…here
: Redirecting to Google Groups
Don’t remember how I did that…really sorry…On Tuesday, March 31, 2015 at 12:24:58 PM UTC+2, Ari Fernelius wrote:

I banged my head to the wall for a day, trying to find out the most
convenient way to read YAML files.
In short: Working with SnakeYAML, I get a structure, from where I can
examine the structKeyList, but can’t access any of the keys.

Example:

file: graphicIDs.yaml

10:
description: Moon
graphicFile: res:/dx9/model/worldobject/planet/moon.red
38:
description: Caldari Frigate Bantam
graphicFile: res:/dx9/model/ship/caldari/Frigate/CF1/CF1_T1.red
sofFactionName: caldaribase
sofHullName: cf1_t1
sofRaceName: caldari

code:

yamlPath = 'c:/databases/'; yamlGraphicIDs = parseYaml(yamlPath & 'graphicIDs.yaml');

function parseYaml(file)
{
Yaml =
createObject(‘java’,‘org.yaml.snakeyaml.Yaml’,‘c:/lucee/lib/snakeyaml-1.15.jar’);
yamlFileData = FileRead(arguments.file);
return Yaml.load(yamlFileData);
}

Now, everything seems to work nicely… #structKeyList(yamlGraphicIDs)#
lists the keys.

But then I hit the brick wall. structKeyExists function does not find any
of the keys. Neither does any bracket notation of the structure. CFDUMP
shows nothing.

Looking at getMetaData() of the returned structure shows it’s a
LinkedHashMap. A normal Lucee structure is a type of StructImpl. Now, I’m
not much of a Java person, so all this is a bit cryptic to me.

I do some Google-fu, and luckily find an old ColdFusion ORM related
solution:
Let’s javacast. #yamlGraphicIds.get(javacast(“int”,10)).description#
works nicely!

Question: Would there be a way to convert the LinkedHashMap structure to a
format that can be cfdumped and manipulated normally?
If I create a new structure with StructNew(), I surely can address numeric
key values without problems, because the structure is of a different type,
native to Lucee.

Cheers,
-Ari