Fix invalid JSON from unescaped backslashes in MQL5 string serialization#294
Open
biohazardxxx wants to merge 11 commits intovdemydiuk:devfrom
Open
Fix invalid JSON from unescaped backslashes in MQL5 string serialization#294biohazardxxx wants to merge 11 commits intovdemydiuk:devfrom
biohazardxxx wants to merge 11 commits intovdemydiuk:devfrom
Conversation
JSONString.toString() in mq5/json.mqh emitted raw strings without escaping special characters. When MQL5 functions returned Windows paths (e.g. TerminalInfoString), backslashes produced invalid JSON causing JsonReaderException on the C# client side. Escape backslash, double-quote, newline, carriage return, and tab characters during serialization, matching the JSON spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JSONString.toString()inmq5/json.mqhemitted raw strings without escaping special characters. When MQL5 functions returned Windows paths (e.g.TerminalInfoString), unescaped backslashes produced invalid JSON, causingJsonReaderException: Bad JSON escape sequenceon the C# client side.json.mqhhas the same latent bug but is worked around by a manualStringReplaceinExecute_TerminalInfoString; this fix addresses it at the serialization layer for MQL5.Test plan
MtApi5.mq5with MetaEditor to verify MQL5 compilation succeedsTerminalInfoStringwith path-returning properties (e.g.TERMINAL_PATH,TERMINAL_DATA_PATH) — verify valid JSON is returned and parsed without exceptions🤖 Generated with Claude Code