Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

get url json

Featured Replies

hello to all.

 

i want to use get url to get json data from a php file.

 

when i run a script i get 3 rows in json.

{"id":"2","userID":"1","app":"1","from_name":"danirub","from_email":"[email protected]","reply_to":"[email protected]","title":"test","plain_text":"","html_text":null,"sent":"1391675943","to_send":"5","to_send_lists":"3","recipients":"5","timeout_check":null,"opens":null,"wysiwyg":"0","send_date":null,"lists":null,"timezone":null,"errors":null,"bounce_setup":"0","complaint_setup":"0"},{"id":"3","userID":"1","app":"1","from_name":"danirub","from_email":"[email protected]","reply_to":"[email protected]","title":"bbbb","plain_text":"","html_text":"

 how can i split the result it to 2 or more records ?

 

Thanks 

Dani

Create a global field g.allfields.

Script:

 

Set Variable[$jsonSplit; YourJsonField]

# delete commas between braces

Set Variable [$jsonSplit; Substitute($jsonSplit; "},{" ; "}{" )]

# delete open braces

Set Variable [$jsonSplit; Substitute ($jsonSplit; "{" ; "" )]

# change close braces to pilcrow to make list

Set Variable [$jsonSplit; Substitute[$jsonSplit; "}" ; "¶" )]

# count number of records to be made

Set Variable [$recordCount ; ValueCount($jsonSplit)]

# create records

Loop

New Record/Request

Set Field [ g.allfields; GetValue($jsonSplit; $recordCount)]

Set Variable [$recordCount; $recordCount - 1]

#

# using the same technique of creating value lists 

# (this time converting the commas into pilcrows),

# parse the name-value pairs in g.allfields 

# into field names and values.

#

Exit Loop If [ $recordCount = 0]

 

Create a global field g.allfields.

...

Loop

New Record/Request

Set Field [ g.allfields; GetValue($jsonSplit; $recordCount)]

Set Variable [$recordCount; $recordCount - 1]

...

 

You are creating a new record and setting a global field to the record's group of values?

You're right, of course; it should NOT be global. I originally was thinking that I needed a global field to store the whole json, before I realized that it could be stored in a variable. Then I didn't delete the word "global" from the post.

  • Author

Thanks very much.

bus some there in not working right.

 

can you have a lock @ the file please ?

 

 

json.fmp12.zip

The JSON in field "a" has two object_name arrays, each of which contains 6 id arrays. Each id array has different name-value pairs. You did not indicate the object_name arrays in your original post.  Exactly what do you wish to have in each record?

  • Author

userID,to_send,id

 

thanks dani

A couple more questions:

 

1. Does your real-world json always include two identical object_name arrays as your sample indicates?

 

2. Your sample data shows that userID and to_send are identical for each id.  Is this the case in your real data?

  • Author

1.yes

2. it is only a test the data will change 

 

Thanks

  • Author

Thanks for the help

  • Author

Ageing thanks for the help.

I suck with  Substitute i am trying to insert data to fields but with no success.

ho do i do it ?

like to insert the data of "from_email" and "to_send"

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.