Skip to content

How to assign a raw json string to a structure value? #954

Answered by kubukoz
mgalera asked this question in Q&A
Discussion options

You must be logged in to vote

let me see if I got it right: given the following

Stuff(Json.obj("hello" := 42))

you want the Json to be serialized as a string?

{"field": "{\"hello\": 42}"}

In this case, your Smithy spec would have to have structure Stuff { @required field: String }, and you'd pass it as Stuff(jsonobj.noSpaces /* or some other rendering */).

or do you just want to pass the Json value verbatim and let it be encoded as json?

{"field": {"hello": 42}}

In this case, Document is fine, but you'll need to go from Json to Document. You can implement this on your side:

object JsonToDocumentFolder extends Folder[Document]:
  override def onNull: Document                    = Document.nullDoc
  override def onString(

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mgalera
Comment options

Answer selected by mgalera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants