Goddard-Fortran-Ecosystem / yaFyaml

Yet Another Fortran YAML
Apache License 2.0
13 stars 8 forks source link

Reading a value inside nested JSON objects fails #10

Closed rouson closed 4 years ago

rouson commented 4 years ago

Reading the JSON file

{ "dag" : { "node" : 1 } }

using the program below error terminates

program main
   use yafyaml, only : Parser, Configuration, FileStream
   implicit none

   type dag_t
     integer :: node = -1
   end type

   type(dag_t) dag
   type(Parser) p
   type(Configuration) c

   p = Parser('core')
   c = p%load(FileStream('nested-objects.json'))
   dag%node = c%at('dag.node')

   if (dag%node /= 1) error stop "Test failed"

   sync all
   if (this_image()==1) print *,"Test passed"
end program
tclune commented 4 years ago

I think this should be

dag%node = c%at('dag','node')  

JSON/YAML keys can have "." in them so you cannot use it as a separator within a string.

rouson commented 4 years ago

Holy moly! 3 minutes to diagnose and respond with a fix. I'm not worthy!

Test passes now. :)