Home

Awesome

<h1 id="json-fortran"><img alt="JSON-Fortran" src="/media/json-fortran-logo-2.png" title="JSON-Fortran logo"></h1>

JSON-Fortran: A Modern Fortran JSON API

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->

Table of Contents

<!-- markdown-toc end -->

Status

Build Status GitHub issues Codecov last-commit

Take a look at the CHANGELOG for a list of changes since the latest release.

top

Brief description

JSON-Fortran is a user-friendly, thread-safe, and object-oriented API for reading and writing JSON files, written in modern Fortran.

top

Download

GitHub release homebrew version Conda (channel only)

Download the official versioned releases here. Or, get the latest development code from the master branch here.

NEWS: As of June 7, 2015, json-fortran can be downloaded and installed with the homebrew package manager on Mac OS X. Once homebrew is installed, make sure that the formulae are up to date, view the package options and caveats, and install the json-fortran formula:

brew update
brew info json-fortran
brew install --with-unicode-support json-fortran

Please note, if you wish to support usage of JSON-Fortran with multiple Fortran compilers, please follow the CMake installation instructions below, as the homebrew installation is only intended to support a single Fortran compiler. Cheers!

NEWS: As of January 20, 2022, json-fortran can be downloaded and installed via the conda package manager on Mac OS X and Linux. Once a conda-distribution, like miniforge, is installed the json-fortran package can be installed.

conda install --channel conda-forge json-fortran

Note: Packages on conda-forge are build with GCC 9.4 which is upwards compatible with newer GCC versions, but not with other Fortran compilers.

Package status from Repology

Packaging status

top

Building the library

The code requires a Fortran compiler that supports various Fortran 2003 and Fortran 2008 features such as: allocatable strings, newunit, generic, class, and abstract interface. It has been successfully compiled with the Intel Fortran compiler 13.1.0 (and greater) and the GNU gfortran compiler [4.9 and greater]. It has also been reported that the library can be built (using the CMake build script) with the NAG Fortran compiler 6.0

Currently, several ways are provided to build the JSON-fortran library (libjsonfortran).

cmake_minimum_required ( VERSION 3.18 FATAL_ERROR )
enable_language ( Fortran )
project ( jf_test NONE )

find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 9.0.2 REQUIRED )

file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" )
foreach ( UNIT_TEST ${JF_TEST_SRCS} )
  get_filename_component ( TEST ${UNIT_TEST} NAME_WE )
  add_executable ( ${TEST} ${UNIT_TEST} )
  target_link_libraries ( ${TEST} jsonfortran::jsonfortran-static )
  # or for linking against the dynamic/shared library:
  # target_link_libraries ( ${TEST} jsonfortran::jsonfortran ) # instead
endforeach()

top

Documentation

The API documentation for the latest release version can be found here. The documentation can also be generated by processing the source files with FORD. Note that both the shell script and CMake will also generate these files automatically in the documentation folder, assuming you have FORD installed.

Some examples can also be found on the wiki.

top

Contributing

Want to help? Take a quick look at our contributing guidelines then claim something and Fork. Commit. Pull request.

top

License

The JSON-Fortran source code and related files and documentation are distributed under a permissive free software license (BSD-style). See the LICENSE file for more details.

top

Miscellaneous

top