Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverse of fieldprefix function #10

Open
Arkoniak opened this issue Jun 20, 2020 · 0 comments
Open

Inverse of fieldprefix function #10

Arkoniak opened this issue Jun 20, 2020 · 0 comments

Comments

@Arkoniak
Copy link

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant