Skip to content

How to check whether a key exists or not? #77

Description

@amalgame21

Sorry I am a begginner in latex.

Take the example.json in README.md as example.

In example.json, the key father is not exist.

How can I check if the key or its value exist or not?

I want to keep using example.json when father key does not exist,
if father key exist, I want to use another-example.json instead.

I tested something like this but not successful

\JSONParseFromFile{\myJSONdata}{example.json}
\ifx\JSONParseValue{\myJSONdata}{father}\empty
  dosomething
\else
  dosomethingelse
  \JSONParseFromFile{\myJSONdata}{another-example.json}
\fi

To be exact, I am trying to manage secrets in json with sops in a latex project.
When the json file is encrypted, it have an extra key called sops like this and it is not ready to be used.
When the json file is decrypted, that sops key disappeared, and it is ready to be used.

Sorry I did not noticed the "Discussions" exists.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions