print the response from a json file

0 favourites
  • 11 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • hello i would like to make to print on screen the server response following the post i would like it to print the title value inside content.

    I wrote this syntax: JSON.Get("message.content.title") but it always returns zero.

    how can i solve i attach the server response.

    also is it possible to ignore a string inside a json file? i would like a string inside the text "qr-data" to be ignored. Thank you very much to anyone who will answer me

    {"QRcodepush":{"payload":{"qr_data":"ALiCzsbVn8pqibwSfgo2l1KmzmC7fiU4owT3A1666003771287"}},"{\n \"payload\":{\n \"qr_data\":\"\",\n \"get_var\":{\n \"get1\":\"valueGet1\",\n \"get2\":\"valueGet2\"\n } \n }\n}":{},"{\"message\":{\"active\":true,\"position\":\"top\",\"delay\":\"3000\",\"style\":{\"width\":\"100%\",\"background\":\"#FF5751\",\"border\":\"2px\",\"borderColor\":\"#FF5751\"},\"icons\":{\"left_ico\":true,\"left_ico_image\":\"fa-solid fa-question\",\"left_ico_color\":\"#00000\",\"left_ico_dim\":\"30px\",\"cancel_ico\":true,\"cancel_ico_color\":\"#000000\",\"cancel_ico_dim\":\"5px\"},\"content\":{\"title\":\"Non riconoscro il QRCODE\",\"title_color\":\"#00000\",\"title_dim\":\"1":{"2em\",\"descr\":\"qr_data: \",\"descrColor\":\"#00000\",\"descr_dim\":\"0":{"8em\"},\"cta\":{\"button\":false,\"button_background\":\"#ffffff\",\"text_button\":\"OK\",\"text_buttonColor\":\"#000000\"}}}":{}}}}

  • Not sure if I understood what you want.

    Do you save Ajax.lastdata inside the JSON? Normally you would catch a response with Ajax and not with JSON.

    For "ignoring part of a string" you could use tokenat().

  • Hi, thank you for your reply.

    I am supposed to scan a qrcode, which has a string inside, ignore it in a json at a certain location and then post it, the response I get from the server a portion I would like to print it on the screen. how can I do it?

    thanks for sharing me the function "tokenat()" now i am going to study it. :)

  • You can create a text object and set its text to JSON.Get(".yourstringlocation").

  • i tried but it doesn't set or set anything. i'm not understanding where i'm going wrong.

  • You are using AJAX wrong. AJAX calls are asynchronous and you need to wait for them to be completed. See the official JSON example, about how to properly use it. There the JSON string is requested from a project file, but the principle is the same. You need to use "On Completed" trigger to load AJAX response into JSON.

    Also, when posting screenshots of your code consider switching the UI to English. I had to guess what some of the lines in your events mean..

  • You're right, I didn't pay attention. I edited the snippet screen in English, I thank you for the effort you made to give me an answer. and I thank you for the advice you are giving me. I will try in the day and give feedback. Thank you very much :)

  • I was finally able to print the message on the response screen from the server.

    But despite several attempts I can't set the string I get inside the json file before posting it.

    {

    "payload":{

    "qr_data":"string must be entered here",

    "get_var":{

    "get1": "valueGet1",

    "get2": "valueGet2"

    }

    }

    }

    any suggestions?

    With the code I entered it inserts it but inserts it in the wrong place.

    thank you very much

  • In the second line the JSON path is wrong. The correct JSON path to set should be ".payload.qr_data".

  • now pass the string correctly, thank you very much!!!

    only now it keeps making the post still with the empty string -.-'

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Guys, I finally succeeded! thank you all so much for the great support you gave me!

    I leave a snippet, for all those who will run into these problems and maybe support them! Thank you very much

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)