如何连接一个字符串和一个对象一起形成一个有效载荷

发布于 2025-02-03 14:32:40 字数 81 浏览 5 评论 0原文

我需要在需要整理一组字符串和一个对象的地方。 哪种方法正在尝试不同的方式但无法做到,请帮助我。 例子- ABC xyz 后空间 { “你好世界” }

I have requirement where I need to put together a set of string and a object.
Which am trying different ways but unable to do so please help me.
example-
abc
xyz
back space
{
"hello":"world"
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

記柔刀 2025-02-10 14:32:40

由于它们是不兼容的类型,因此无法将对象和字符串连接在一起。但是,您可以将对象“打印”到字符串,然后将其连接。

示例:

%dw 2.0
output application/java
var payload1={ "employee": "sara", "categories": { "id": "employee01", "name": "sara" } }
var payload2="QU sara world BACF MESSAGE"
---
write(payload1,"application/java") ++ " " ++ payload2

输出(类型字符串的输出):{雇员= sara,类别= {id =雇员01,name = sara}} qu sara world bacf message

An object and a string can not be concatenated together since they are of incompatible types. However you can "print" the object to a string, and then concatenate it.

Example:

%dw 2.0
output application/java
var payload1={ "employee": "sara", "categories": { "id": "employee01", "name": "sara" } }
var payload2="QU sara world BACF MESSAGE"
---
write(payload1,"application/java") ++ " " ++ payload2

Output (of type string): {employee=sara, categories={id=employee01, name=sara}} QU sara world BACF MESSAGE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文