Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
131
rated 0 times [  134] [ 3]  / answers: 1 / hits: 31070  / 13 Years ago, sat, january 28, 2012, 12:00:00

I would like to parse YAML in the browser. Ideally I'm looking for a browser-ready library. The ones I've found are not written to run in a browser (they make synchronous calls to require() or assume the existence of an exports variable).



Alternatively, I'll accept example code that shows how to load a YAML-parsing library into the browser via RequireJS.


More From » parsing

 Answers
62

Similar question: JavaScript YAML Parser.



The most promising library that seems to work in the browser is js-yaml. A snippet from the project page for loading the library in HTML:



<script src=js-yaml.min.js></script>
<script type=text/javascript>
var doc = jsyaml.load('greeting: hellonname: world');
</script>


They claim to also support AMD loaders like RequireJS.



Here is the browserified version of the library: with comments and minified.


[#87767] Thursday, January 26, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
siena

Total Points: 199
Total Questions: 91
Total Answers: 91

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;