Skip to main content
Solved

experssion for string

  • Oct 14, 2022 9:00 AM UTC
  • 10 replies
  • 125 views

asadamjad
Participant
Forum|alt.badge.img+12

i need to get the email address from this

 

[{""email"":""228_mg_primarydistribution@hotmail.com""}]

 

 

And

 

{

 "token": "-QPWNTxHkE4R1TM8u_M1AOUohy0X2i69BMJBEy0oUDZnqugzS4IKCWiAMrI6YqbLDxJKDyahZ0vrhoAj7FQ49EM4AWkxohFN54D5vJJLzxxR6M_3xcb2mI4iG8E0WDj3fR1my34kAB0_oRNcfNlueTm-jwpxb-OI6WxCJoLkvzaF9y74XYmGUbBeISz1Wmr-U5nFxUCrXbVOtEt5bd9Qh5qwrc9nZeZ6W7uP0oUyXs-wmqHxFxXOl7dhho4LmD-0bo2525vNwKvEZRsgfn6ep8WC264IfwNW7h7UvFX1d6Y.",

 "expires": 1665744258308,

 "ssl": true

}

 

and other query i need extract only bold values

Best answer by asadamjad

for 2nd i get this error

 

image

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

10 replies

david_r
Celebrity
  • Oct 14, 2022 10:19 AM UTC

For the first one you can use a JSONExtractor with the following expression:

json[0]["email"]

This will extract the first element of the outer JSON list, then retrieve the value of the "email" key within that element.

It's pretty much the same for the second one, except that there's no list, so you can query the value directly:

json["token"]

You can read more about these expressions in the documentation: https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/jsonfragmenter.htm#JSON_Queries

This one is perhaps the best introduction if you're not too familiar with JSON: https://community.safe.com/s/article/tutorial-getting-started-with-json


asadamjad
Participant
Forum|alt.badge.img+12
  • Author
  • Participant
  • Oct 14, 2022 12:17 PM UTC

its rejecting

 

 imageimageimage


asadamjad
Participant
Forum|alt.badge.img+12
  • Author
  • Participant
  • Best Answer
  • Oct 14, 2022 12:22 PM UTC

for 2nd i get this error

 

image


david_r
Celebrity
  • Oct 14, 2022 1:15 PM UTC

The configuration of the JSONExtractor is most likely wrong. It should look something like this:

image


asadamjad
Participant
Forum|alt.badge.img+12
  • Author
  • Participant
  • Oct 14, 2022 2:02 PM UTC

give me same error


asadamjad
Participant
Forum|alt.badge.img+12
  • Author
  • Participant
  • Oct 14, 2022 2:05 PM UTC

fin the attach WS


david_r
Celebrity
  • Oct 14, 2022 2:47 PM UTC

fin the attach WS

The attachement only contains the log, not the workspace. Can you please rather post a screenshot of your JSONExtractor settings.


david_r
Celebrity
  • Oct 14, 2022 2:49 PM UTC

its rejecting

 

 imageimageimage

The configuration of the JSONExtractor in the screenshot above is wrong, please compare to the screenshot I posted below.


asadamjad
Participant
Forum|alt.badge.img+12
  • Author
  • Participant
  • Oct 14, 2022 3:04 PM UTC

 

imageimage


david_r
Celebrity
  • Oct 14, 2022 3:08 PM UTC

 

imageimage

Check if the quotes (") of the contents of attribute sent_to are doubled, they seem to be in the example at the top of this post, and that's not valid JSON.

If yes, you can use a StringReplacer to replace "" with " before the JSONExtractor.