从单元格中选择特定的JSON值

huangapple go评论61阅读模式
英文:

Select specific json value from cell

问题

[{"value":"+44 1234 98715963","isPrimary":true},{"value":"+44 7784 9122","isPrimary":false}]

在Google表格中,我有一些以JSON(或类似JSON的)格式呈现的信息,例如:

我尝试通过公式和/或脚本实现以下目标:在新单元格中显示标志为“isPrimary”等于true的值。
在上面的示例中,该值为+44 1234 98715963。

英文:

In a Google Sheet, I have information in a json (or json-like?) format as e.g.:

[{"value":"+44 1234 98715963","isPrimary":true},{"value":"+44 7784 9122","isPrimary":false}]

What I am trying to achieve (via formula and/or script) is the following: Show the value where the flag "isPrimary" equals true in a new cell.
In the above example that would be +44 1234 98715963

答案1

得分: 1

=如果您希望在value:isPrimary:true之间直接删除数值,而不一定是查找确切的模式,您可以尝试以下代码:

=index(if(len(A2:A),regexextract(substitute(A2:A,"""",""),":([^:]*),isPrimary:true"),))
英文:

If you wish to bluntly remove the value b/w value: & isPrimary:true but definitely not looking for some exact pattern inside, you may give a shot at:

=index(if(len(A2:A),regexextract(substitute(A2:A,"""",""),":([^:]*),isPrimary:true"),))

从单元格中选择特定的JSON值

答案2

得分: 0

=REGEXEXTRACT(B1, ".*""(+\d+ \d+ \d+)"" ""isPrimary"":true")

英文:

Try this formula

=REGEXEXTRACT(B1,".*""(\+\d+ \d+ \d+)"",""isPrimary"":true")

(Do adjust the formula according to your ranges and locale)

从单元格中选择特定的JSON值

huangapple
  • 本文由 发表于 2023年3月7日 03:50:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75655232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定