Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Saturday, May 14, 2016 5:23 AM
Hello,
I am developing a windows console application in C# to parse js files. I don't want to EXECUTE javascript file. I want to check if a file is a valid js file or not. How do I parse the file using C#? I looked at JScript.JSParser(). I am not sure how to use it. Any help is appreciated.
Thanks,
psy
All replies (3)
Saturday, May 14, 2016 6:15 AM âś…Answered | 1 vote
Hi,
I would use the jint project to parse a java script. I don't know the JScript.JSParse() that you mentioned.
jint can be found at https://github.com/sebastienros/jint and it can be used to parse a whole script. (Using JavascriptParse.Parse(string).
That way you would use the parser of the JavaScript intepreter.
With kind regards,
Konrad
Saturday, May 14, 2016 11:42 AM
Hi psy_spy,
As Konrad Neitzel mentioned jint, I also strongly recommend you to take a look at it because it is very good for your needs to parse Javascript to C#.
Take a look at this codeplex page about jint: http://jint.codeplex.com/
It's also available on nuget: https://www.nuget.org/packages/Jint
And on GitHub as Konrad mentioned at: http://github.com/sebastienros/jint
Hope this was helpful for you.
Best regards!
(If this was helpful for you, vote for it and propose it as an answer)
Wednesday, January 31, 2018 7:07 PM
Is there any way to edit one of the JavaScript expressions programmatically and then write to a different JavaScript file using Jint?
I have been looking for a way to do this, but Jint's Parser does not seem to provide any way to write the JavaScript again after a program or expression is loaded in memory. No Write() method seems to be available and ToString() does not write JavaScript.
This functionality seems to be highly desirable, so my suspicion is that I am just missing it, not that it is not implemented.
Any ideas on where it could be?