Ocean West Posted May 20, 2020 Posted May 20, 2020 Here is a bit of code to cover the return separated list of NFC scan results to a json object. While ( [ data = $parameter ; dataRows = ValueCount ( data ) ; z = 5; records = (dataRows - 4) / 4; row = 0 ; rec = "" ; // First Four Rows json = JSONSetElement ( "" ; [ "reason" ; GetValue ( data ; 1 ) ; JSONString ] ; [ "error" ; GetValue ( data ; 2 ) ; JSONString ] ; [ "param" ; GetValue ( data ; 3 ) ; JSONString ] ; [ "mulitiline" ; GetValue ( data ; 4 ) ; JSONString ] ; [ "records" ; records ; JSONNumber ] ) ] ; row < records ; [ rec = JSONSetElement ( "" ; [ "id" ; GetValue ( data ; z ) ; JSONString ] ; [ "param" ; GetValue ( data ; z+1 ) ; JSONString ] ; [ "type" ; GetValue ( data ; z+2 ) ; JSONString ] ; [ "format" ; GetValue ( data ; z+3 ) ; JSONString ] ); json = JSONSetElement ( json ; "record[" & row & "]" ; rec ; JSONObject ) ; row = row + 1 ; z = z + 4 ] ; JSONFormatElements (json) ) returns returns { "error" : "", "mulitiline" : "1", "param" : "The current date and time is 5/7/2020 2:46:26 PM", "reason" : "TagRead", "record" : [ { "format" : "1", "id" : "", "param" : "123456", "type" : "T" }, { "format" : "1", "id" : "", "param" : "abc", "type" : "T" }, { "format" : "1", "id" : "", "param" : "door 4", "type" : "T" }, { "format" : "1", "id" : "", "param" : "Sunday ", "type" : "T" }, { "format" : "1", "id" : "", "param" : "fmp19://$/Write%20Data.fmp12", "type" : "U" }, { "format" : "1", "id" : "", "param" : "https://www.twitter.com/fmforums", "type" : "U" } ], "records" : 6 }
Recommended Posts
This topic is 1646 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now