如何在informatica中获取json格式的数据?

发布于 2025-01-14 07:20:55 字数 657 浏览 0 评论 0原文

我在平面文件中有 ID 和电子邮件,我正在使用表达式转换,创建了一个字符串数据类型的输出端口,尝试将值传递为以下

'[
  {
   "Id":"'||Id||'"
   "email":"'||email||'"
  }
 ]'

输出:

"[
  {
   "Id":"2904"
   "email":"[email protected]"
  }
 ]"

我不需要在方括号的开头和结尾处使用“”行结束后不应有多余的空格。

预期输出:

 [
  {
    "Id":"2904"
    "email":"[email protected]"
   }
  ]

我会将此字符串作为 http 请求传递给 API Web 服务。请帮助提供所需的格式。

I have Id and email in flat file, I am using expression transformation, created an output port as string data type, trying to pass the value as below

'[
  {
   "Id":"'||Id||'"
   "email":"'||email||'"
  }
 ]'

output:

"[
  {
   "Id":"2904"
   "email":"[email protected]"
  }
 ]"

I don't need the " " at the start and end for square braces and no extra space should be there after line ends .

expected output:

 [
  {
    "Id":"2904"
    "email":"[email protected]"
   }
  ]

I will pass this string to the API webservice as http request. Kindly help with required format.

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

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

发布评论

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

评论(1

自由如风 2025-01-21 07:20:55

在 exp 转换中创建以下端口和逻辑。

--assuming input column is datacol
var_str1 = LTRIM(substr(datacol, substr(datacol,'output: '))) -- This will result everything after the word output:.
var_str2 = substr( var_str1 ,2) -- removes first double quote
var_str3 = substr( var_str2 ,-1) -- removes last double quote
out_str= var_str3

我一步一步地完成了它们。如果您觉得方便,请将所有内容合并为一行。
编辑
var_* - 这表示这些是可变端口。
out_ - 此输出是可变端口。

In exp transformation create below ports and logic.

--assuming input column is datacol
var_str1 = LTRIM(substr(datacol, substr(datacol,'output: '))) -- This will result everything after the word output:.
var_str2 = substr( var_str1 ,2) -- removes first double quote
var_str3 = substr( var_str2 ,-1) -- removes last double quote
out_str= var_str3

I did them in step by step process. if you are comfortable, pls combine all into one line.
EDIT
var_* - this denotes these are variable ports.
out_ - this output these are variable ports.

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