StructTypes.jl
StructTypes.jl copied to clipboard
Inverse of `fieldprefix` function
There is fieldprefix function, which transform flat structure into nested objects. Is it possible in some way to have an opposite operation?
As an example, consider following article structure written in json: Input:
json_str = """
{
"author": {
"name": "XXX"
"link": "https://example.com"
},
"title": "YYY",
"body": "ZZZ"
}
"""
What I want is to put it in flat structure (because in my particular case I do not need author as a separate object)
struct Article
author_name::String
author_link::String
title::String
body::String
end
And to be able to read articles with the construct like
JSON3.read(json_str, Article)