Skip to main content
Solved

experssion for string

  • October 14, 2022
  • 10 replies
  • 41 views

Forum|alt.badge.img+5

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

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
  • October 14, 2022

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


Forum|alt.badge.img+5
  • Author
  • October 14, 2022

its rejecting

 

 imageimageimage


Forum|alt.badge.img+5
  • Author
  • Best Answer
  • October 14, 2022

for 2nd i get this error

 

image


david_r
Celebrity
  • October 14, 2022

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

image


Forum|alt.badge.img+5
  • Author
  • October 14, 2022

give me same error


Forum|alt.badge.img+5
  • Author
  • October 14, 2022

fin the attach WS


david_r
Celebrity
  • October 14, 2022

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
  • October 14, 2022

its rejecting

 

 imageimageimage

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


Forum|alt.badge.img+5
  • Author
  • October 14, 2022

 

imageimage


david_r
Celebrity
  • October 14, 2022

 

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.