save Json - Forum

Forum Navigation
You need to log in to create posts and topics.

save Json

How do I save the information of a web service that is displayed in the browser as Json in a text file?

For example:
https://api.codebazan.ir/numberofcharacters/index.php?text=Friday

(2) is displayed:
result "result": "true", "Numberofcharacters": 6}

I want to save part (2) in a text file

You might find this plugin helpful @s7shanbe.    https://zmware.rcmediaservices.net/zmwjson/


Later

I must apologize, as I didn't click your link first.   You don't need any fancy JSON for this.    If you use Internet GET you can then parse what you need out of the simple return.    If you need help with that, let me know.

Quote from s7shanbe on May 4, 2022, 4:01 pm

How do I save the information of a web service that is displayed in the browser as Json in a text file?

For example:
https://api.codebazan.ir/numberofcharacters/index.php?text=Friday

(2) is displayed:
result "result": "true", "Numberofcharacters": 6}

I want to save part (2) in a text file

@s7shanbe,

Try this code with your link above.  NOTE that the GET command of Neo's can't handle SSL apparently so we just knock off the "s" from https and it works fine.

...  VisualNeo is not able to handle SSL so it appears, so I am using the non secure variant of the URL (http)

InternetGet "http://api.codebazan.ir/numberofcharacters/index.php?text=Friday" "[Result]" ""

...  strip out the brackets and quotes

StrReplace "[Result]" "}" "" "[Result]" ""
StrReplace "[Result]" "{" "" "[Result]" ""
StrReplace "[Result]" "[#34]" "" "[Result]" ""

...  Divide the Value pairs.

StrParse "[Result]" "," "[Part]" "[TotalParts]"

         Loop "1" "[TotalParts]" "[x]"
         
         ...   Now divide the values from the pairs

              StrParse "[part[x]]" ":" "[[x]Value]" "[m]"
 
         Endloop


         SetVar "[ReturnedResult]" "[1Value2]"
         SetVar "[NumberOfChars]" "[2Value2]"  
         
AlertBox "Values Returned" "Result = [1Value2]|Number of Chars = [2Value2]"

The final two setvars are not required.  They are there for illustration.

Let me know how that works out for you.

 

 

 

 

luishp and Vadim have reacted to this post.
luishpVadim