RussellSpitzer / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 1 forks source link

Parsing multidimensional array #165

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create multidimensional array (Double[][][] weight)
2. Dump it. My dump looks like:

!!jailibrary.BasicStructure
function: !!jailibrary.SigmoidalFunction {}
hiddenLayersCount: 1
hiddenNeuronsSizes: [2]
inputLayerSize: 4
outputLayerSize: 4
weights:
- - [-5.7855340159344975, 6.391058034908343, -4.898270739235223, 
3.80241100406204, -0.4181628620974109]
  - [-4.780729632685992, 5.185100785736257, 5.460538218689736, -6.127283837890756, -0.04953490116064775]
- - [-15.297894284897312, -14.678007960620098, 6.873882038095056]
  - [13.37170571894871, 12.882660101636331, -19.820490340355864]
  - [-14.804057108901775, 14.621970628181957, -7.5768397188668395]
  - [14.715839948961465, -15.47193956749274, -7.262953745888246]

3. Try to parse it. 

What is the expected output? What do you see instead?
Expected: created Object.
Instead:

Exception in thread "main" Can't construct a java object for 
tag:yaml.org,2002:jailibrary.BasicStructure; exception=Cannot create 
property=weights for JavaBean=jailibrary.BasicStructure@15ad1da; array element 
type mismatch
 in 'string', line 1, column 1:
    !!jailibrary.BasicStructure
    ^
What version of SnakeYAML are you using? On what Java version?
SnakeYAML: 1.11, Java: SE 1.7

Original issue reported on code.google.com by Kamil.So...@gmail.com on 18 Dec 2012 at 4:16

GoogleCodeExporter commented 9 years ago
Arrays of primitives are not supported. It is connected to issue 
http://code.google.com/p/snakeyaml/issues/detail?id=135

There is no planning to support it in the nearest future. This is due to no 
support for arrays in the Java Introspection API.

Original comment by py4fun@gmail.com on 19 Dec 2012 at 1:29

GoogleCodeExporter commented 9 years ago
It was not array of primitives. I was array of Double's, not double's: 
Double[][][] weights.

Original comment by Kamil.So...@gmail.com on 19 Dec 2012 at 1:43

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It is the same problem. Java Introspection API does not provide the type of the 
elements of arrays at runtime.
To make it more clear: Java does not have multidimensional arrays. What you 
provide is an array where the values are primitives (arrays).

You can create the array as list of lists and then assign it to your business 
object. But it requires to code your own way to create an instance.

Original comment by py4fun@gmail.com on 20 Dec 2012 at 3:16

GoogleCodeExporter commented 9 years ago
Since there is no clarification form the reporter the issue is closed

Original comment by py4fun@gmail.com on 22 Jan 2013 at 5:19