Sign in to follow this  
Followers 0
macjos

[Samples] read json custom function without plugin, FileMaker only

1 post in this topic

read json custom function without plugin, FileMaker only


Being unsatisfied with solutions I found on the internet and wanting a solution without plugin I created a set of custom functions that can read a path out of a json-string.

 

Syntax:

 

json_path ( json-string ; path )

 

 

examples:

 

json_path( $user_prefs ; "Privileges/Modules" )

json_path( $json_data ; "Menus/Menu[10]/MenuItem[5]/Label" )

 


  • Submitter
  • Submitted
    09/30/2016
  • Category
  • FM Version
    FM Version: 14

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By macjos
      Being unsatisfied with solutions I found on the internet and wanting a solution without plugin I created a set of custom functions that can read a path out of a json-string.
       
      Syntax:
       
      json_path ( json-string ; path )
       
       
      examples:
       
      json_path( $user_prefs ; "Privileges/Modules" )
      json_path( $json_data ; "Menus/Menu[10]/MenuItem[5]/Label" )
       
    • By Anthony
      I am using a custom function to format a number into currency format ( two decimals ). 
      RoundDecimals(11.0) = 11.00 The problems occurs when I use a variable:
      $amount = 11.0 RoundDecimals($amount) = 11.11 Similarly, I get the same error using a string:
      RoundDecimals("11.0") = 11.11  
      Is there any tricks to get around this issue ? 
      This is the custom function that I used (I replaced the comma for a dot and defaulted second parameter to 2):
      https://www.briandunning.com/cf/974
       
    • By Steven Cappiello
      Hi everyone,
      I'm trying to post data to a Drupal application from FileMaker via the BaseElements plugin. I'm getting a token, setting authentication, headers, and the post variables via the BaseElements functions and I've followed examples but I'm getting the following error:  {"error":"The type link relation must be specified.”}    I can't find any information about what this error might be. Does anyone have any idea based on the output I've gathered below?
      A working cURL command that I'm basically trying to replicate  that can be run from the command line is here:
      curl --include \   --request POST \   --user res_user:"password" \   --header 'Content-type: application/hal+json' \   --header "X-CSRF-Token: $X_CSRF_TOKEN" \   --data-binary '{"_links":{"type":{"href":"http://server.mskcc.org/rest/type/node/event"}},   "field_event_type":[{"value":"Seminar"}],   "title":[{"value":”Novel Approaches to Mating Drosophila"}],   "field_shared_datetime":[{"value":"2016-06-13T17:15:00"}],   "body":[{"value":"Tea ?: Yes<br>Tea Time: Tea at 1:15 PM"}],   "field_shared_location_text":[{"value":"ZRC Auditorium"}],   "field_shared_sponsor":[{"value":"Developmental Biology"}],   "field_event_hosts_text":[{"value":"Alexander Rudensky"}],   "field_shared_people_text":[{"value":"Name of Speaker: Steven Reiner<br>Speaker\u0027s Credentials: M.D.<br>Speaker\u0027s Title: Professor, Department of Microbiology and Immunology<br>Speaker\u0027s Affiliation: Columbia University Medical Center<br>Institution Location: New York, NY"}],   "type":[{"target_id":"event"}]}' \ http://dev.mskcc.org/entity/node?_format=hal_json I've attached the script I'm working with as an image.
      thanks in advance.
      Steven
       
      -----
       
      BE_Curl_Trace returned:
      == Info:   Trying 172.22.233.50...
      == Info: Connected to dev.mskcc.org (172.22.233.50) port 80 (#0)
      == Info: Server auth using Basic with user 'res_user'
      => Send header, 0x12c bytes (0x12c)
      0000: POST /entity/node?_format=hal_json HTTP/1.1
      0x2d: Host: server.mskcc.org
      0x42: Authorization: Basic cmVzX2RydXBhbDpUcnU3SCZrQQ==
      0x75: User-Agent: libcurl-agent-base-elements-plugin/3.2
      0xa9: Accept: */*
      0xb6: Content-Type: application/hal+json
      0xda: X-CSRF-Token: q3LKwzWvNtlP2_X79TpJATfEnOB8HV-_lDaVCiTK8gg
      0x115: Content-Length: 353
      0x12a: 
      => Send data, 0x161 bytes (0x161)
      0000: " {\"_links\":{\"type\":{\"href\":\"http://dev.mskcc.org/rest/ty
      0x40: pe/node/event\"}},..  \"field_event_type\":[{\"value\":\"Seminar
      0x80: \"}],..  \"title\":[{\"value\":\"Sister Cells that Feast and Fas
      0xc0: t --- Why Growth and Repair May Not be Fair XI\"}],..  \"field_s
      0x100: hared_datetime\":[{\"value\":\"2016-06-13T17:15:00\"}],..  \"typ
      0x140: e\":[{\"target_id\":\"event\"}]}"
      == Info: upload completely sent off: 353 out of 353 bytes
      <= Recv header, 0x1a bytes (0x1a)
      0000: HTTP/1.1 400 Bad Request
      <= Recv header, 0xf bytes (0xf)
      0000: Server: nginx
      <= Recv header, 0x24 bytes (0x24)
      0000: Content-Type: application/hal+json
      <= Recv header, 0x1c bytes (0x1c)
      0000: Transfer-Encoding: chunked
      <= Recv header, 0x18 bytes (0x18)
      0000: Connection: keep-alive
      <= Recv header, 0x18 bytes (0x18)
      0000: Keep-Alive: timeout=10
      <= Recv header, 0x33 bytes (0x33)
      0000: Cache-Control: must-revalidate, no-cache, private
      <= Recv header, 0x1a bytes (0x1a)
      0000: X-UA-Compatible: IE=edge
      <= Recv header, 0x16 bytes (0x16)
      0000: Content-language: en
      <= Recv header, 0x21 bytes (0x21)
      0000: X-Content-Type-Options: nosniff
      <= Recv header, 0x1d bytes (0x1d)
      0000: X-Frame-Options: SAMEORIGIN
      <= Recv header, 0x28 bytes (0x28)
      0000: Expires: Sun, 19 Nov 1978 05:00:00 GMT
      <= Recv header, 0x25 bytes (0x25)
      0000: Date: Wed, 03 Aug 2016 11:02:45 GMT
      <= Recv header, 0x2 bytes (0x2)
      0000: 
      <= Recv data, 0x40 bytes (0x40)
      0000: 35
      00x4: {"error":"The type link relation must be specified.”}      <——— here's the error
      0x3b: 0
      0x3e: 
      == Info: Closing connection 0
       
      BE_Response_Headers returned:

      HTTP/1.1 400 Bad Request
      Server: nginx
      Content-Type: application/hal+json
      Transfer-Encoding: chunked
      Connection: keep-alive
      Keep-Alive: timeout=10
      Cache-Control: must-revalidate, no-cache, private
      X-UA-Compatible: IE=edge
      Content-language: en
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      Expires: Sun, 19 Nov 1978 05:00:00 GMT
      Date: Wed, 03 Aug 2016 11:02:45 GMT
       
    • By shevyshevy
      I am having difficulty removing the .JPG extension from the file name of my imported pictures. The Pictures are actually students pictures saved with the student's ID Numbers.
      Example SLT-098-00034.jpg  ,  SLT-088-11123.jpg
      I am trying to extract the real ID Numbers from the File names which should be in this format  SLT/098/33322
      Accomplishment So Far..
      Using the Substitute function,  Substitute (text; searchstring; replacestring)  , I have been able to convert the file name from SLT-098-00034.jpg  to SLT/098/00034.jpg
      Now, I want to remove the .jpg extension, but can't achieve that using the Substitute function..  Please is there a better way to achieve this?