[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJAVal object is not correctly assigned to another CJAVal object as object (not array) #1

Closed
vivazzi opened this issue Mar 22, 2021 · 1 comment

Comments

@vivazzi
Copy link
Owner
vivazzi commented Mar 22, 2021

Failed case:

#include <JAson.mqh>

int OnInit(){
    CJAVal data;

    // simple structure
    data["a"] = 12;

    // nested structure
    CJAVal nested_data;
    nested_data["k1"] = 7;
    nested_data["k2"] = "baz";
    
    data["b"] = nested_data;
    
    Print(data["b"]["k1"].ToInt());  // 0 instead of 7
    Print(data["b"]["k2"].ToStr());  // "" instead of "baz"
    Print(data.Serialize());  // {"a":12,"":{"k1":7,"k2":"baz"},"b":{}} instead of {"a":12,"b":{"k1":7,"k2":"baz"}}
}

As workaround, you need use Set() method:

data["b"].Set(nested_data);
Print(data["b"]["k1"].ToInt());  // 7
Print(data["b"]["k2"].ToStr());  // "baz"
Print(data.Serialize());  // {"a":12,"b":{"k1":7,"k2":"baz"}}

I tryed fix this bug, but I have no deep knowledge of the language in mql (c++) and I can not fix this bug.

If anyone can help, then many MQL-developers will be grateful as this bug has been around for many years.

@vivazzi vivazzi closed this as completed in 2df29ad Apr 4, 2021
@vivazzi
Copy link
Owner Author
vivazzi commented Apr 4, 2021

Thanks to Laszlo Tormasi, who fixed this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant