Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3939 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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]

 

Posted

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?

Posted

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.

Posted

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?

Posted

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?

This topic is 3939 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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