Problem with custom JSON Tagger

1 Answer 129 Views
SyntaxEditor
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 09 Feb 2023, 01:39 AM

First, thanks for the awesome stuff, getting it going was easy.

However, I'm having a few issues and can't seem to figure out a way around them.  I'm trying to make a JSON tagger.

Here is how I'm defining things:


    Private Shared ReadOnly Keywords As String() = New String() {""""}
    Private Shared ReadOnly Operators As String() = New String() {"{", "}", "[", "]", ":", ","}


Here is an example of the output

The problems I see are:

The second double quote isn't colored like the first one.

The colon isn't colored

The comma after the double quote isn't colored

The closing brace and comma aren't colored

Also, is there a way to highlight the text between characters?  I'd like to highlight the keys and values, and differently from each other if possible.

I'm sure I'm doing it wrong, but haven't been able to figure it out.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Feb 2023, 11:44 AM

Hi, Troy,

RadSyntaxEditor doesn't offer JSON tagger. However, it offers a convenient mechanism for creating a custom tagger or language. A sample approach is demonstrated in the following help articles: 
https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/taggers/custom-language
https://docs.telerik.com/devtools/winforms/controls/syntax-editor/features/taggers/custom-taggers

You can also refer to our Demo application >> SyntaxEditor examples for your reference. You can also have a look at the internal implementation of the built-in CSharpTagger by downloading the source code: https://docs.telerik.com/devtools/winforms/installation-and-upgrades/download-product-files

In the CSharpTagger there is a StringPattern const defined. It represents the StringMatchingRegex pattern used to match strings in the documents which this tagger recognizes in the GetTags method. The SplitIntoWords method inheriting from the WordTaggerBase class is responsible for splitting the document into words. So if you want to achieve any parsing logic that is not currently available in RadSyntaxEditor, you have the possibility to do it.

The following tutorial demonstrates how to attach the Telerik source code to your project in order to investigate how the built-in CSharpTagger works and splits the words so you can use a similar approach:
https://docs.telerik.com/devtools/winforms/knowledge-base/attach-telerik-source-code-to-your-project

I believe that the following forum post and the sample approach there would be also useful for achieving your custom requirement: 
https://www.telerik.com/forums/syntax-highlighting-strings-(custom-language)#5154587
I hope this information helps. If you need any further assistance please don't hesitate to contact me.  

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
SyntaxEditor
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or