jacobwilliams / json-fortran

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

Passing JSON as parameter #467

Closed ghost closed 3 years ago

ghost commented 4 years ago

I'm developing a C++ application that uses nlohmann::json API. Link here: https://github.com/nlohmann/json

I would like to call a Fortran function passing a JSON as a input argument.

extern "C" {
    void my_fortran_fun(nlohmann::json myJson);
}

int main() 
{
...
    my_fortran_fun(my_json);
---
}

Is it possible?

jacobwilliams commented 4 years ago

JSON-Fortran isn't going to understand the C++ structure (and C++ isn't going to understand the Fortran structure). Probably you could do it by serializing the JSON to a string?

jacobwilliams commented 4 years ago

See also #371 and #429.