OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
json_helpers.hpp File Reference

JSON utility functions for configuration parsing. More...

#include <nlohmann/json.hpp>
#include <string>
Include dependency graph for json_helpers.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using pfc::ui::json = nlohmann::json
 

Functions

json pfc::ui::get_json_value (const json &j, const std::string &key, const std::string &section="")
 Helper function to get a JSON value from either flat or nested structure.
 

Detailed Description

JSON utility functions for configuration parsing.

This header provides helper functions for working with JSON configuration objects, particularly for handling both flat and nested JSON structures.

Author
OpenPFC Development Team
Date
2025

Function Documentation

◆ get_json_value()

json pfc::ui::get_json_value ( const json &  j,
const std::string &  key,
const std::string &  section = "" 
)
inline

Helper function to get a JSON value from either flat or nested structure.

Supports both flat access (j["Lx"]) and nested access (j["domain"]["Lx"]). Checks nested location first if the key doesn't exist at top level.

Parameters
jJSON object to search
keyKey to look for
sectionOptional section name (e.g., "domain", "timestepping")
Returns
JSON value if found, otherwise json(nullptr)
Here is the call graph for this function:
Here is the caller graph for this function: