Skip to content

API Questions and Critiques #497

Open
@everythingfunctional

Description

@everythingfunctional

Based on this example usage (although perhaps there are more examples that make this clearer, if so please point me towards them), it is unclear to me how the arguments to the get calls correspond to what data this example expects to have been in the file. Perhaps you could add a comment there to specify what it should be?

Based on that example, it appears that get is a generic interface, and thus the specific procedure is determined based on the type of the argument. So how does one determine what the actual type of an element in the JSON is? And is it possible to access an array of elements of different types?

Suppose I'm trying to deserialize a compound object, is it possible to "get" an object to pass to the constructor of one of the components. I.e.

function compound_from_json(json) result(compound)
  type(json_file), intent(in) :: json
  type(compound_t) :: compound

  type(??) :: first_component, second_component, ...

  call json%get('first', first_component)
  call json%get('second', second_component)
  ...
  compound%first_component = first_component_t(first_component)
  compound%second_component = second_component_t(second_component)
  ...
end function

Do you have an example of constructing the JSON? Is it easy to compose for e.g. serializing a compound object like above?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions