Skip to content

Dealing with raw json #1257

@valentin-panalyt

Description

@valentin-panalyt

I have a question similar to #306 and I wonder if there is a better solution to that after 5 years.

Basically, sometimes I get a json structure that contains a field (let's call it raw_payload) that contains more raw json without a schema. I want to just forward that raw_payload and store it in the database and/or return it in my API. I don't care what exact json is inside that field, but it needs to be valid json.

Example 1:

{
    "foo": 1,
    "bar": 2,
    "raw_payload": [{"random": "stuff"}]
}

Example 2:

{
    "foo": 1,
    "bar": 2,
    "raw_payload": {"even": {"more": "random", "stuff": [1,2,3] } }
}

I'd like to map that into case class Data(foo: Int, bar: Int, raw_payload: SomeRawJsonType)

What's currently the best approach to achieve that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions