User Tag List

Results 1 to 2 of 2

Thread: How to get an array element in a JSON string?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Ls2's Avatar
    Join Date
    Jun 2011
    Location
    Maceiˇ - Brazil
    Posts
    938
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How to get an array element in a JSON string?

    Hello!

    I'm facing a problem with JSON Object. I have a JSON string:

    Code:
    {
        "total_num_of_post": 3,
        "response_from": 0,
        "posts": [{
            "date_time": "2022-05-15 18:47:35",
            "author": "1",
            "recipient": "0",
            "content": "foo ba",
            "num_of_replies": "0",
            "important": "0",
            "seen_by": ","
        }, {
            "date_time": "2022-05-15 18:47:31",
            "author": "1",
            "recipient": "0",
            "content": "ba",
            "num_of_replies": "0",
            "important": "0",
            "seen_by": ","
        }]
    }
    I need to get every element (date_time, author, recipient, etc.) in array "posts". How can I achieve this? I think that I'm using the "loop through all sub-objects" wrongly...

    Thank you.

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Ls2's Avatar
    Join Date
    Jun 2011
    Location
    Maceiˇ - Brazil
    Posts
    938
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I found a solution...

    * Button Button clicked
    Edit Box : Set text ""
    JSON Object : Enter Object named ("posts")
    JSON Object : Loop ("foo") through all sub-objects

    * JSON Object: On Sub-Object Loop "foo"
    Edit Box : Set text Edittext$( "Edit Box" ) + NewLine$ + ObjSubStringValue$( "JSON Object", "date_time" )

    This will get the date_time values.

Similar Threads

  1. retrieving array values from JSON string
    By hamdi369 in forum Fusion 2.5
    Replies: 0
    Last Post: 20th October 2021, 09:30 AM
  2. Replies: 3
    Last Post: 2nd January 2021, 07:29 AM
  3. String Parser empty element?
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 13th February 2017, 02:01 AM
  4. String Parser question - sort by 3rd element?
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 29th July 2012, 06:12 AM
  5. Changing an element of a delimited string
    By keokeo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 11th September 2011, 02:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •