Json.xshd fix
JNaumann86 opened this issue · 2 comments
Hi people,
I just found an error in the json color scheme.
If the json value is an object and the opening brace of the object begins on next line after the colon, then the next key value pairs will be treated as String / value and not as FieldName / key.
Json.xshd:
This is the fix for the bug, but I am not allowed to create a new branch / pull request :(
We would like to use this control in our app. But therefor the color scheme should be corrected :)
I hope to hear from you :)
Thank you very much!
Partial style with fixes:
<RuleSet name="String">
<Span begin="\\" end="."/>
</RuleSet>
<RuleSet name="Object">
<Span color="FieldName" ruleSet="String">
<Begin>"</Begin>
<End>"</End>
</Span>
<Span color="FieldName" ruleSet="String">
<Begin>'</Begin>
<End>'</End>
</Span>
<Span color="Punctuation" ruleSet="Expression" multiline="true">
<Begin>:</Begin>
<End>,</End>
</Span>
</RuleSet>
<RuleSet name="Array">
<Import ruleSet="Expression"/>
<Span color="Punctuation">
<Begin>,</Begin>
</Span>
</RuleSet>
<RuleSet name="Expression">
<Keywords color="Bool" >
<Word>true</Word>
<Word>false</Word>
</Keywords>
<Keywords color="Null" >
<Word>null</Word>
</Keywords>
<Span color="String" ruleSet="String">
<Begin>"</Begin>
<End>"</End>
</Span>
<Span color="String" ruleSet="String">
<Begin>'</Begin>
<End>'</End>
</Span>
<Span color="Punctuation" ruleSet="Object" multiline="true">
<Begin>\{</Begin>
<End>\}</End>
</Span>
<Span color="Punctuation" ruleSet="Array" multiline="true">
<Begin>\[</Begin>
<End>\]</End>
</Span>
<Rule color="Number">
\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?
</Rule>
</RuleSet>
<RuleSet>
<Import ruleSet="Expression"/>
</RuleSet>
We found also another bug with json arrays:
The second element of the array in a single line will not be recognized and all keys following the array will be treated as string.
Partial style with both fixes:
<RuleSet name="String">
<Span begin="\\" end="."/>
</RuleSet>
<RuleSet name="Object">
<Span color="FieldName" ruleSet="String">
<Begin>"</Begin>
<End>"</End>
</Span>
<Span color="FieldName" ruleSet="String">
<Begin>'</Begin>
<End>'</End>
</Span>
<Span color="Punctuation" ruleSet="Expression" multiline="true">
<Begin>:</Begin>
<End>,</End>
</Span>
</RuleSet>
<RuleSet name="Array">
<Import ruleSet="Expression"/>
<Keywords color="Punctuation">
<Word>,</Word>
</Keywords>
</RuleSet>
<RuleSet name="Expression">
<Keywords color="Bool" >
<Word>true</Word>
<Word>false</Word>
</Keywords>
<Keywords color="Null" >
<Word>null</Word>
</Keywords>
<Span color="String" ruleSet="String">
<Begin>"</Begin>
<End>"</End>
</Span>
<Span color="String" ruleSet="String">
<Begin>'</Begin>
<End>'</End>
</Span>
<Span color="Punctuation" ruleSet="Object" multiline="true">
<Begin>\{</Begin>
<End>\}</End>
</Span>
<Span color="Punctuation" ruleSet="Array" multiline="true">
<Begin>\[</Begin>
<End>\]</End>
</Span>
<Rule color="Number">
\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?
</Rule>
</RuleSet>
<RuleSet>
<Import ruleSet="Expression"/>
</RuleSet>
We are already using this style in our app and it works good :)
I didn't notice this issue at first, but I made a PR which fixes this (albeit in a different way): #418.