jacobwilliams/json-fortran

API Questions and Critiques

everythingfunctional opened this issue · 1 comments

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?

Yep, I can work up an example for you when I get a chance.

The documentation does need to be improved. See also #233. Note: you could also look at the src/tests but it's not really that user friendly to find what you need. What we need are some examples written as use cases for common things that users might want to do.