array.html 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <script src="../../dist/jsoneditor.js"></script>
  6. </head>
  7. <body>
  8. <textarea class="debug" cols="30" rows="10"></textarea>
  9. <button class='get-value'>Get Value</button>
  10. <div class='container'></div>
  11. <script>
  12. var container = document.querySelector('.container');
  13. var debug = document.querySelector('.debug');
  14. var schema = {
  15. "type": "array",
  16. "title": "Nodes",
  17. "items": {
  18. "type": "object",
  19. "title": "Node",
  20. "properties": {
  21. "node": {
  22. "type": "string",
  23. "title": "I am a node"
  24. }
  25. }
  26. }
  27. };
  28. var editor = new JSONEditor(container, {
  29. schema: schema
  30. });
  31. document.querySelector('.get-value').addEventListener('click', function () {
  32. debug.value = JSON.stringify(editor.getValue());
  33. });
  34. </script>
  35. </body>
  36. </html>