Parse Telegram JSON message by line break - telegram-bot

I'd like to remove the line breaks from the telegram text message using MQL4 coding. I'd like to convert the text to a format that MT4 can use to place a trade.
The issue is that the telegram bot is reading the chat and the text is converted to a one-liner with the \n separator. I need to split the different parts of the message into separate Int/Str/Double, etc. so that I can use them to place the trade using MQL4 code.
The message format is as follows:
"text":"XRPUSD\nBUYLIMIT\n0.15010\nSL 0.18000\nTP 0.14000"
This message comes in as msg.message_text but I don't see the actual message unless I use Postman. I just know the format from a JSON converter library.
Again, I need to split the different parts of the message into separate Int/Str/Double, etc, so that I can use them to place the trade using MQL4 code.
Hopefully, I am asking and presenting the data in a manner that makes sense. Please let me know.
Thanks

I think you can use StringReplace method
Like this
string text="XRPUSD\nBUYLIMIT\n0.15010\nSL 0.18000\nTP 0.14000";
int replaced=StringReplace(text,"\n","/");
Print("Replaced: ", replaced,". Result=",text);

Related

Pentaho rest client with variable url

I'm new to Pentaho and using the Rest Client. I can get the Rest client to work by using generate rows for the url. But then I need to pass part of the result of the json to be part of the url for the next request. I'm not sure how to do this. Any suggestions.
Remember that PDI works with streams, you, for each REST request you made, you will have one row as result. You will have as many rows as many requests you do.
I'm not sure if you can deserialize the JSON object directly from the PDI interface, but in the worst scenario, you can use the "User Defined Java Class" to use some external library (like Gson) and deserialize the object.
Then, you can create another variable in the UDJC step and concatenate the attributes you need on the URL string that comes from the last step.
In the other hand you can use "Modified Javascript" to deserialize it and return the attributes you need to then concatenate it with the URL. To use it, just declare varibles inside the code, and then use "Get variables" button to retrieve the available fields to send to the next step.
There are many ways to do it, I suggest you to use the Modified Javascript because it's easier to handle.
You CAN parse the Json response, just use Json Input a a nex step, and then use XPath to parse the field you want: $.result.the.thing.u.want.

Advantages of using a JSON string in the POST body as opposed to using key/value pairs in the POST body

What are the advantages of using a JSON string in the POST body as opposed to using key/value pairs in the POST body? It seems like there are a lot of API's out there that do it.
Example of what I mean: user={"username":"bob", "age":1} vs username=bob&age=1 in the POST form data.
When you use a JSON string, you just have to encode/decode your object and are ready to go. This especially useful when using multiple platforms.
Also, when you want to add new values/fields to your request, you just add it to the JSON object, instead of having to add extra validations in multiple files, possibly breaking code already works.
Another thing I can think of is that when using JSON you can code one single component with the only purpose of send/receive data, where you declare the function that will receive the decoded JSON and do whatever it wants with it. That way, you don't repeat code and let every function/class/file/whatever do the specific functionality it's meant to.

Modifying code to recive only RMC output in GPS

I am using GPS module for my application. I want only the RMC data. So what am I supposed to do in my code to get only this data, i.e all the other formats like GGA,GSA,VTG should be disabled.
Please Help.
Thanks
You cannot disable the other messages, and there is no reason to do so. Some GPS units support commands to enable/disable messages, but it is anything but standard.
Simply use a switch statement in your code on the sentence identifying field, and have a case block for GPRMC.

Feed API: are their any API exist to read the feed easily

Suppose I have 10 feed URLs.
If I want to read them, I need to make 10 requests and I need to parse every response. Sometimes the feed is not well-defined, I may get an error when my parser parses them.
Are there any APIs to read the feed by making a request to them and then give me a result through response or JSON?
That would mean making 1 request instead of 10, no need to parse the result and make less processing. Are their any APIs to do that?
Yes, there is : http://superfeedr.com/
We do normalize the data, deal with the polling or find the best way to get that content in realtime. Finally, we push that content to you, in the format that you want (Atom or JSON).

VB.NET - Read lines from command line to Windows form possible?

Hey Overflow, I have an application which serves as a user interface for a spartan/command line program.
I have the program running on a separate process, and my application monitors it to see if it is responding and how mush CPU it is utilising.
Now I have a list of files in my program (listbox) which are to be sent to the application, which happens fine. But I want to be able to read text from the com-line so as to determine when the first file has been processed.
Com-line says one of "selecting settings", "unsupported format" and "cannot be fixed".
What I want to be able to do is when it says one of these three things, remove item(0) in listbox1.
Is this possible?
I thought of programming an event which handles com_exe.print or something or other, if possible.
Read the standard output from the process.
MSDN Article
Theres an example of synchronous reading from the process in that article.
You might be able to do what you want using the AttachConsole API function as described here. However, maybe an easier alternative would be if you could pipe the output of the command line app to a text file and then your app could just parse the text file (assuming that the command line file wouldn't lock the file completely, I'm not sure about that).
If you don't know how to pipe the output, this page has quite a bit of information.