We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

JSon Language Configuration

Does anyone have a language configuration for parsing Json files?

5 Replies

VR Venkateshwaran Ramdoss Syncfusion Team August 10, 2016 11:16 AM UTC

Hi Ron, 
 
Thank you for contacting Syncfusion Support. 
 
The custom language can be configured in the EditControl by using the configuration file. By configuring the custom language in the EditControl, you can define the syntax coloring based on the requirement. The following steps help you to configure the syntax coloring for the Json language. 
 
 
Step 1(Initialize the configuration language): Set the configured language by using the ConfigLanguage tag attribute.  
 
For an example: <ConfigLanguage name="Json" StartComment="//" CaseInsensitive="true" >  
 
Step 2(Extensions): Extensions contain a list of extensions that are associated with that particular language. 
 
Step 3(Splits): Splits contain a list of expressions that must be treated as one word. “=” and “+” are splitters, by default. So, each of them are returned by the tokenizer as a single char. For example, when you want to specify a configuration for “+=”, you should specify “+=” in the splits section. 
 
Step 4(Formats): This section helps you to initialize the Format strings. The Format assigns the syntax coloring for the keywords, text, comment tag, etc. 
 
Step 5(Lexems): The Lexem contains rules for parsing the text. There are two attributes to specify the format of the lexem. 
·       Type: The Type is used for standard predefined types of the lexems. 
·       FormatName: The FormatName is used only when Type is Custom. 
 
Step 6(AutoReplaceTriggers): The AutoReplaceTrigger option helps you to autocorrect the mistakes in the EditControl. 
 
For an example:  
 
<AutoReplaceTriggers> 
  <AutoReplaceTrigger From="slef" To="self" /> 
</AutoReplaceTriggers> 
 
Step 7: After configuring the custom language, the configured file can be applied to the EditControl by using the Configurator.Open function in the EditControl. 
 
Step 8: The text coloring of the specified language can be applied to the EditControl by using the ApplyConfiguration function in the EditControl. 
 
For an example: 
 
// Opens the PowerShell file. 
this.editControl1.LoadFile(@"..\\..\\Sample.json"); 
//Configures the Custom Language File. 
this.editControl1.Configurator.Open(@"..\\..\\Config.xml"); 
//Applies the Custom Language configuration to the EditControl. 
this.editControl1.ApplyConfiguration("Json"); 
 
You can refer the below KB link for brief explanation of syntax highlighting for Custom Language Configuration. 
 
KB Link:  
 
We have prepared a sample to Parsing Json language in EditControl using above stepsfor your reference and you can download the sample and screenshots from the below link.  
 
 
We request you to check with the above solution and let us know if it helps.  
 
Regards, 
Venkateshwaran V.R. 



KE Ken replied to Venkateshwaran Ramdoss February 23, 2020 11:02 PM UTC

Hi Ron, 
 
Thank you for contacting Syncfusion Support. 
 
The custom language can be configured in the EditControl by using the configuration file. By configuring the custom language in the EditControl, you can define the syntax coloring based on the requirement. The following steps help you to configure the syntax coloring for the Json language. 
 
 
Step 1(Initialize the configuration language): Set the configured language by using the ConfigLanguage tag attribute.  
 
For an example: <ConfigLanguage name="Json" StartComment="//" CaseInsensitive="true" >  
 
Step 2(Extensions): Extensions contain a list of extensions that are associated with that particular language. 
 
Step 3(Splits): Splits contain a list of expressions that must be treated as one word. “=” and “+” are splitters, by default. So, each of them are returned by the tokenizer as a single char. For example, when you want to specify a configuration for “+=”, you should specify “+=” in the splits section. 
 
Step 4(Formats): This section helps you to initialize the Format strings. The Format assigns the syntax coloring for the keywords, text, comment tag, etc. 
 
Step 5(Lexems): The Lexem contains rules for parsing the text. There are two attributes to specify the format of the lexem. 
·       Type: The Type is used for standard predefined types of the lexems. 
·       FormatName: The FormatName is used only when Type is Custom. 
 
Step 6(AutoReplaceTriggers): The AutoReplaceTrigger option helps you to autocorrect the mistakes in the EditControl. 
 
For an example:  
 
<AutoReplaceTriggers> 
  <AutoReplaceTrigger From="slef" To="self" /> 
</AutoReplaceTriggers> 
 
Step 7: After configuring the custom language, the configured file can be applied to the EditControl by using the Configurator.Open function in the EditControl. 
 
Step 8: The text coloring of the specified language can be applied to the EditControl by using the ApplyConfiguration function in the EditControl. 
 
For an example: 
 
// Opens the PowerShell file. 
this.editControl1.LoadFile(@"..\\..\\Sample.json"); 
//Configures the Custom Language File. 
this.editControl1.Configurator.Open(@"..\\..\\Config.xml"); 
//Applies the Custom Language configuration to the EditControl. 
this.editControl1.ApplyConfiguration("Json"); 
 
You can refer the below KB link for brief explanation of syntax highlighting for Custom Language Configuration. 
 
KB Link:  
 
We have prepared a sample to Parsing Json language in EditControl using above stepsfor your reference and you can download the sample and screenshots from the below link.  
 
 
We request you to check with the above solution and let us know if it helps.  
 
Regards, 
Venkateshwaran V.R. 


Is it possible for others to access this example?  I tried but got access denied.  Thank you!


UN Unknown Syncfusion Team February 24, 2020 10:41 AM UTC

Hi Ken, 

Thanks for contacting Syncfusion support. 

We have checked your query ”The sample from the forum is not downloadable” and we have attached the requested sample below for your reference. 


Regards, 
Niranjan Kumar Gopalan 



AP Adam Pawsey April 27, 2021 10:10 AM UTC

Hi,

I should start by saying the controls you make are fantastic, and thank you for making the community edition available!

I'm struggling with the syntax editor (EditControl) control.  The documentation regarding the lexems is severely lacking, to be able to get the correct behaviour out of them.

Is there any chance of getting it updated?  The main concerns is there is not enough detail around how the various properties interact with each other to process the text.

My objective is to create proper json syntax highlighting, but the samples you provide are incomplete or overly complicated.  I'm not looking for you to provide the answer, but to provide the information I need to solve the problem myself, and hopefully benefit anyone else who wants to use this control.

Thanks,
Adam.


EM Elakkiya Muthukumarasamy Syncfusion Team April 29, 2021 02:24 AM UTC

Hi Adam, 
 
Thanks for your update. 
 
We have checked your queries and we would like to let you know that can you please update us while creating json syntax highlighting in EditControl, which kind of problem you have faced. So that we can check further and update the document based on your requirement. 
 
Please update the below details which is helpful to provide the prompt solution on this. 
 
1.Which kind of problem while trying the provided details regarding the lexems in our documentation. 
2.Please try it with the previously provided sample and update us the code or properties which is complicated your side. 
3.Possible modify the sample as issue reproduceable  
 
Regards, 
Elakkiya 


Loader.
Live Chat Icon For mobile
Up arrow icon