Jump to content
Sign in to follow this  
AlanTrewartha

[Solutions] fmresultsetjson.xsl

Recommended Posts

fmresultsetjson.xsl


XSLT to convert Filemaker's REST web-service XML response into clean JSON

https://twitter.com/alantrewartha

2017-03-06

Adapted from the original Six Fried Rice XSLT here http://sixfriedrice.com/wp/products/filemaker-to-json-converter/

Changed:
* single quotes to JSON-standard double-quotes
* removed "fieldDefinitions" block (personal preference)
* stopped every field value being presented as an [ array ] even when not a "repeating field"
* added whitespace escaping code

The white-space escaping code was entirely cribbed from
https://github.com/doekman/xml2json-xslt/blob/master/xml2json.xsl


 

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  

  • Similar Content

    • By jayivan
      I am working on an API integration from FileMaker 17 to Emma. Generally when I work on a new API, I get the curl working on the command line and then translate that into FM. But I've hit a roadblock with one particular API call while my other API calls to Emma are successful. (In the example below, I substituted out sensitive data with all caps.)
      From the command line, the code is:
      curl -u USER:PASS -H "Accept:application/json" -H "Content-type: application/json" -X POST -d '{"fields": {"name_first": "TESTFIRST","name_last": "TESTLAST","eligible": "false","expiration": "@D:2019-06-30"},"group_ids": ["GROUPIDNUMBER"],"email": "EMAIL@EMAIL.COM","opt_in_confirmation": "false"}' "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"
      This command is successful.  The server responds with the individuals' emma id and group confirmation. 
      This fails using Insert from URL within FM though. While eventually I'll use FileMaker fields for an individual record's names, email, and expiration dates, I did not use fields in my testing in order to duplicate the command line exactly. In Insert from URL:
      The URL is "https://api.e2ma.net/ACCOUNTNUMBER/members/signup"
      The curl option is "-u USER:PASS -H \"Accept:application/json\" -H \"Content-type: application/json\" -X POST -d '{\"fields\": {\"name_first\": \"TESTFIRST\",\"name_last\": \"TESTLAST\",\"eligible\": \"false\",\"expiration\": \"@D:2101-06-30\"},\"group_ids\": [\"GROUPIDNUMBER\"],\"email\": \"EMAIL@EMAIL.COM\",\"opt_in_confirmation\": \"false\"}'"
       
      Can anyone identify the problem or suggest a workaround? My experience with API integration with FM is limited, but anything I could get working via the command line, I've been able to get working within FM until this.
    • By kigmaker
      Hello,
      I would like to use UUIDdecimal CF for the taskID rather than an auto-enter Serial Number. However I get Integer Notation like this:
      2.25640703445567e+37, rather than a number like this:
      22564070344556677882256407034455667788.
      I have toyed with other implementations of FullCalendar and have gotten it to work, but the related libraries were different versions and I can't recall how I solved the same problem then.
      How can I solve this?
      Example
      {
      "allDay" : false,
      "color" : "#FF0000",
      "end" : "2018-05-30T23:00:00**TIMEZONE**",
      "id" : 9,
      "start" : "2018-05-30T21:00:00**TIMEZONE**",
      "title" : "New Task"
      },
      {
      "allDay" : false,
      "color" : "#E69138",
      "end" : "2018-06-01T23:30:00**TIMEZONE**",
      "id" : 2.25640703445567e+37,
      "start" : "2018-06-01T22:30:00**TIMEZONE**",
      "title" : "Old Task"
      }
    • By Pavlk
      I've attached two files. The first one is INVOICE, that is generated by every establishment when you purchase, and is in xml format.
      The second one is XSLT file, that is provided by government fiscal institution and is used to "translate" xml.
      PROBLEM DESCRIPTION: when I try to decode xml using attached xslt scheme on any online xml-converter website the output looks fine. BUT when importing to Filemaker, I receive an error: "XML parsing error: invalid document structure".
       
      I would appreciate any help with the issue. Thanks.
      XML input.xml
      XSLT scheme.xslt
    • By _Mark__
      Hi all,
      I'm completely new to XML and I'm making an XLST for an XML feed into my Filemaker database.
      Surprisingly, I got the basics down rather fast, but I'm really stumped on a few fields.
      See attached XLST, sample dataset and Filemaker test database.
      Referencing the XSLT metadata, the import works perfectly fine for the nodes named 'titleId' down through 'dealType' as well as the nodes under 'licensingWindow'. However I can't seem to get the values of a few other nodes. The trouble for me is that the nodes are nested in as child nodes that aren't named uniquely and I just can't figure out how to get their values.
      Example:
      <titleListingTextSets>
                  <listingTexts>
                      <listingText>
                          <name>SYNOPSIS75</name>
                          <value>Mickey continues to feel mounting pressure from the network.</value>
                      </listingText>
                      <listingText>
                          <name>SYNOPSIS234</name>
                          <value>Mickey continues to feel mounting pressure from the network as an affiliates dinner is fast approaching and they need something to sell to advertisers.</value>
                      </listingText>
                      <listingText>
      What I'm looking for is the value (text beginning with the word Mickey) of the field 'value' on the node under the ones whose name is 'name' containing the values 'SYNOPSIS75' and 'SYNOPSIS234'. Those values seem to be the only way to uniquely identify the 'value' fields. That's what I'm not getting. I had one try that did correctly identify and pull over the value data but it messed with the overall for-each I need for importing a number of records and thus I only got the data for a single record.
      I'm guessing there is an easy fix for this, but I'm just not familiar enough with XML to know it yet.
      I'd really appreciate it if someone could point me toward the right technique to use on this.
      You'll see in my XLST some of my failed attempts, if you'd like to see what I was trying.
      Thanks in advance,
      Mark
      NO_SYNOPSES_OR_LICENSE.xslt
      XML_TEST.fmp12
      Sample_Data.xml
×

Important Information

By using this site, you agree to our Terms of Use.