Brian Dunning's FileMaker Custom Functions

@JsonFindKey ( json ; key )

Returns a list of paths to each instance of the specified key.

  Average rating: 4.5 (2 votes) Log in to vote

Alex Zueiv   Alex Zueiv - Show more from this author
Tashkent
https://github.com/zueiv

Share on Facebook Share on Twitter

  Sample input:
@JsonFindKey ( "{\"a\\\b\":{\"c.d\":[{\"e\":1}]}}" ; "e" )
  Sample output:
.a\b.['c.d'][0].

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Returns a list of paths to each instance of the specified key.
To get the found element or its sibling, add the key to the path.

 

Comments

Oscar   Oscar, Oscar
Sep 25, 2022
Hello Alex, thanks for your function.
Did you create any custom functions for returning the path from a value, I know you wrote this:

"Let ( [

ARR = Substitute (
JSONSetElement ( "[]" ; 999 ; "{\"x\":1}" ; JSONObject ) ;
"null" ; "{\"x\":0}"
) ;
QTY = ValueCount ( JSONListKeys ( ARR ; "" ) ) ;
SZ = Length ( ARR ) ;

START = Get ( CurrentTimeUTCMilliseconds ) ;
x = While ( [
LST = JSONListValues ( ARR ; "" ) ;
i = 0 ; r = ""
] ;
i < QTY and r = "" ;
[
i = i + 1 ;
o = GetValue ( LST ; i ) ;
r = If ( JSONGetElement ( o ; "x" ) = 1 ; o )
] ;
r
) ;
TEST_A = Get ( CurrentTimeUTCMilliseconds ) - START ;"

There is a custom function to this?

Thanks for your comment
 
Alex Zueiv   Alex Zueiv, Tashkent
Sep 25, 2022
Hello Oskar,

I think this is what you are looking for:

https://www.briandunning.com/cf/2617

You may also want to look at the JSONQuery() CF available here:

https://filemakerhacks.com/?s=JSONQuery
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: