jacobwilliams / json-fortran

A Modern Fortran JSON API
https://jacobwilliams.github.io/json-fortran/
Other
338 stars 86 forks source link

Cleanup of API for reading and writing #397

Closed jacobwilliams closed 5 years ago

jacobwilliams commented 5 years ago

I'm thinking of adding read and write generic procedures to replace (or that could be used in addition to) the various routines:

Or also maybe also consider UDDTIO?

zbeekman commented 5 years ago

UDDTIO would be really nice.

dongli commented 5 years ago

Why not just give users json_file and json_value objects, what is the meaning of json_core. I find difficulties to figure out the paradigm.

jacobwilliams commented 5 years ago

json_file is the high-level interface. json_core is a class with all the methods for manually manipulating the JSON pointer structures (this is available for use by the user if they want, and is also used internally by json_file).

jacobwilliams commented 5 years ago

Perhaps the new API should be:

json_file.print          ! json_file_print_to_console (me                  )
                         ! json_file_print_to_unit    (me,           iunit )
                         ! json_file_print_to_filename(me, filename        )
json_file.load           ! json_file_load             (me, filename, unit  )
json_file.serialize      ! json_file_load_from_string (me, str             )
json_file.deserialize    ! json_file_print_to_string  (me, str             )

json_core.print          ! json_print_to_console (json,       p           )
                         ! json_print_to_unit    (json,       p, iunit    )
                         ! json_print_to_filename(json,       p, filename )
json_core.load           ! json_parse_file       (json, file, p, unit     )
json_core.serialize      ! json_parse_string     (json,       p, str      )
json_core.deserialize    ! json_value_to_string  (json,       p, str      )