Skip to content

Inverse of fieldprefix function #10

Open
@Arkoniak

Description

@Arkoniak

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions