JuliaData / JuliaData/StructTypes.jl
Inverse of `fieldprefix` function
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 86
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing fieldprefix function and how JSON3.read(json_str, Article) handles nested fields. Define the inverse mapping needed for author.name and author.link to populate author_name and author_link, with successful deserialization into the shown Article structure as the completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100