json is a well-established format, it's convenient for me to have 100% one-to-one classes in C# and in MQL , and to organize loading models into runtime - so far there's a deadlock in that direction
and pass binary data here and there.... Well, it's not a novelty and only lazy person can do it)))
ZS: Python also seems to work with json without any problems, i don't know what Metaquotes has given to pythonists with its new MT5 capabilities - just pump out historical data? - whats the point? it was not the problem, imho
namespace ConsoleApp4
{
publicclass Rootobject
{
public Test test { get; set; }
publicint a { get; set; }
publiclong b { get; set; }
}
publicclass Test
{
publicint a { get; set; }
publicfloat b { get; set; }
publicstring t { get; set; }
}
class Program
{
staticvoid Main(string[] args)
{
var obj = new Rootobject { a = 555, b = long.MinValue, test = new Test { a = 10, b = 0.369 F, t = "Hi" } };
string json = JsonSerializer.Serialize<Rootobject>(obj);
Console.WriteLine(json);
Console.ReadLine();
}
}
}
Сериализация и десериализация JSON-протокола. Портированный код со скоростной библиотеки С++. Практичный пример: авторизация на сайте и парсинг ответа Благодарности принимаются в виде примеров, кто как применяет MQL для работы с веб-ресурсами. Поделитесь своим опытом работы с JSON в MQL. В протокол добавлены функции Escape / Unescape...
You have a very specific understanding of the term 'self-forming':
Apparently the solution is more convenient because you have had your problem solved for you and you've got a taste for it...
It's hard to suggest what drives you, if you wanted to help, you helped, if you didn't want to, you closed the thread and went on with your business
and once again trying to discuss personal characteristics of forum members.... you should get married, sirin" - there will be someone to take a ride over your head when you have nothing better to do.
for the point:
i'm trying to figure out where to put the square bracket, but the results are disappointing.
It's hard to guess what motivates you, if you wanted to help, you helped, if you didn't want to, you closed the thread and went about your business.
and once again try to discuss personal characteristics of forum participants.... in general, "you should get married, sir!" (s) - there will be someone to pick your brains when you have nothing better to do.
for the point:
i'm trying to figure out where to put the square bracket, but the results are disappointing.
if I get bored with the selection, I'll stick [] in with dirtier tricks )))
PS. Looks like we'll have to put it in the "kodobase"))))
imho, great job, there are questions of course, how quickly you made it.... if here in the course of this one hour.... well that's kind of over the top!
checked the edited version - ok, everything works correctly
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
put it in the Buy More.
imho, it's the right thing!
json is a well-established format, it's convenient for me to have 100% one-to-one classes in C# and in MQL , and to organize loading models into runtime - so far there's a deadlock in that direction
and pass binary data here and there.... Well, it's not a novelty and only lazy person can do it)))
ZS: Python also seems to work with json without any problems, i don't know what Metaquotes has given to pythonists with its new MT5 capabilities - just pump out historical data? - whats the point? it was not the problem, imho
Laziness. I don't need it (json) yet.
C#
result:
C#
{"test":{"a":10,"b":0.368999988,"t":"Hi"},"a":555,"b":-9223372036854775808}
MQL:
{"test":{"a":10,"b":0.369,"t":"Hi"},"a":555,"b":-9223372036854775808}
definitely a WILDERFUL!
;)
I suspect I'm already boring you with my wishes, but I need arrays of objects
on my own, I can't ((()
need such an example:
the result should be:
{"test":[{"a":4,"b":0.4,"t":"8"},{"a":3,"b":0.3,"t":"6"},{"a":2,"b":0.2,"t":"4"},{"a":1,"b":0.1,"t":"2"},{"a":0,"b":0.0,"t":"0"}],"a":555,"b":-9223372036854775808}
I suspect I'm already bored with my wishes, but I need arrays of objects
myself, I can't (((
Please tell me, maybe I missed it somewhere, but still,
what exactly is your problem with the ready-made json serialisation/deserialisation solution?
Can you tell me if I missed it somewhere, but still,
what exactly is your problem with an out-of-the-box json serialisation/deserialisation solution?
The KB solution allows you to generate object fields in json by yourself.
the solution proposed by@Vladimir Simakov makes it more convenient
the KB solution implies independent generation of object fields in json
in the solution proposed by@Vladimir Simakov this is done more conveniently
You have a very specific understanding of the term "independent generation":
Apparently it's more convenient to have your task solved for you and you've got the taste for it...
You have a very specific understanding of the term 'self-forming':
Apparently the solution is more convenient because you have had your problem solved for you and you've got a taste for it...
It's hard to suggest what drives you, if you wanted to help, you helped, if you didn't want to, you closed the thread and went on with your business
and once again trying to discuss personal characteristics of forum members.... you should get married, sirin" - there will be someone to take a ride over your head when you have nothing better to do.
for the point:
i'm trying to figure out where to put the square bracket, but the results are disappointing.
if I get bored with the selection, I'll stick [] in with dirtier tricks )))
It's hard to guess what motivates you, if you wanted to help, you helped, if you didn't want to, you closed the thread and went about your business.
and once again try to discuss personal characteristics of forum participants.... in general, "you should get married, sir!" (s) - there will be someone to pick your brains when you have nothing better to do.
for the point:
i'm trying to figure out where to put the square bracket, but the results are disappointing.
if I get bored with the selection, I'll stick [] in with dirtier tricks )))
Fixed it and added processing of pointers to serializable objects at the same time.
PS. Looks like I'll have to put it into "kodobaza"))))
it should be like this (line break is not necessary - I added it by hand):
{"test":[ {"a":0,"b":0.0,"t":"0"}, {"a":1,"b":0.1,"t":"2"}, {"a":2,"b":0.2,"t":"4"}, {"a":3,"b":0.3,"t":"6"}, {"a":4,"b":0.4,"t":"8"}], "a":555,"b":-9223372036854775808}now it's like this:
{"test":[ "{" a":0," b":0.0," t":"0"}", "{" a":1," b":0.1," t":"2"}", "{" a":2," b":0.2," t":"4"}", "{" a":3," b":0.3," t":"6"}", "{" a":4," b":0.4," t":"8"}"], "a":555,"b":-9223372036854775808}PS. Looks like we'll have to put it in the "kodobase"))))
imho, great job, there are questions of course, how quickly you made it.... if here in the course of this one hour.... well that's kind of over the top!
checked the edited version - ok, everything works correctly