Hey guys, I created a type
public type User={
name:Text;
age:Nat;
hobbies:[Text];
};
Then I want to return User into a json format data in the Response of http_request.
return {
body = Text.encodeUtf8(USERJSON);
headers = [("Content-Type","application/json;charset=utf-8")];
status_code = 200;
};
If I pass in the data directly, it is successful
body=Text.encodeUtf8("{name:'tom',age:11}");
So I need to construct this Text type data, the stupid way is to use Text.concat to splice into a paragraph of text.
I want to ask
- Is there any way to convert type data into Text or Blob?
- Is there any better way to splice a long text with parameters?