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

Json.xshd fix #410

Open
JNaumann86 opened this issue Aug 21, 2023 · 2 comments · May be fixed by #418
Open

Json.xshd fix #410

JNaumann86 opened this issue Aug 21, 2023 · 2 comments · May be fixed by #418

Comments

@JNaumann86
Copy link

JNaumann86 commented Aug 21, 2023

Hi people,

I just found an error in the json color scheme.

Bug
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:
Fix
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>
@JNaumann86
Copy link
Author

JNaumann86 commented Aug 24, 2023

We found also another bug with json arrays:
Bug2
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.

This is the fix:
Fix2

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 :)

@ltrzesniewski ltrzesniewski linked a pull request Dec 18, 2023 that will close this issue
@ltrzesniewski
Copy link
Contributor

I didn't notice this issue at first, but I made a PR which fixes this (albeit in a different way): #418.

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

Successfully merging a pull request may close this issue.

2 participants