0

Say i have a json file called by "scene1.json", and i want the content to get printed on the html screen without server anything since i using mobile notepad app for testing html file and script.

  1. How to write the divs and their spans into json? Like of the content is

<section>
<div class="someclass" data-text="current_scene" value="1">
<span class="otherclass">Some paragraph</span>
</div>
</section>

all that normal html stuffs?

  1. How to get that all to get taken and printed into div in html that run normally in jQuery? Like what TAJS by Etienne Ott works. But i can’t understand how it all works.
Woobie
  • 95
  • 7
  • I can make efficient my work if i can separate them in different json files rather than in a very long single html file. The created game engine’s script has only one html page. The script processing the elements in html. So even when it all is successfully get printed, maybe like with .html(), i hope the game script will still recognize them. – Woobie Apr 06 '21 at 11:50
  • @Quentin - I recognise you're trying to help, but the OP wants to know if and / or how it is possible to serialize HTML Markup as JSON. The question you have associated with this question is not similar at all. – Rounin Apr 06 '21 at 11:50
  • Security policy? What makes it to be different to when it all is written in the file? – Woobie Apr 06 '21 at 11:59
  • Regrettably I can't answer your question below because that won't be possible unless and until the question is successfully re-opened, but you should know that there is no standards-body-approved approach of serializing HTML Markup as JSON. [1/2] – Rounin Apr 06 '21 at 12:00
  • That said, I developed my own HTML-to-JSON serialization approach in late 2017 which has undergone a few small modifications since then and which I still use now (as part of **Da3SH**). As a _Da3SH Markup Component_ your HTML above would look like this: `[{"element":"section","elementChildren":[{"element":"div","classList":["someclass"],"attributes":{"value":"1"},"dataset":{"text":"current_scene"},"elementChildren":[{"element":"span","classList":["otherclass"],"elementChildren":[{"plainText":"Some paragraph"}]}]}]}]`. [2/2] – Rounin Apr 06 '21 at 12:02
  • It’s a little bit complex, far longer rather than what i thought, still i’ll working that. Thank you. – Woobie Apr 06 '21 at 12:26
  • It's entirely up to you, @Woobie. I've only posted the JSON to show you what I work with. You're absolutely welcome to modify it or make it more concise however you wish. – Rounin Apr 06 '21 at 12:34
  • Wish i could also become a help. But i know i’m only newbie to it all complexity. The lines are twice longer in a JSON, but in one page HTML, the notepad could become heavy and long scroll. – Woobie Apr 06 '21 at 22:53
  • 1
    Are you looking to make your HTML Markup more concise? Is that your main objective, In that case, rather than **JSON**, you should look at something like [**Emmet**](https://emmet.io/). See: https://www.sitepoint.com/faster-workflow-mastering-emmet-part-1/ – Rounin Apr 07 '21 at 10:28

0 Answers0