Solved

experssion for string


Badge +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

icon

Best answer by asadamjad 14 October 2022, 14:22

View original

10 replies

Userlevel 4

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

Badge +5

its rejecting

 

 imageimageimage

Badge +5

for 2nd i get this error

 

image

Userlevel 4

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

image

Badge +5

give me same error

Badge +5

fin the attach WS

Userlevel 4

fin the attach WS

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

Userlevel 4

its rejecting

 

 imageimageimage

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

Badge +5

 

imageimage

Userlevel 4

 

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.

Reply