TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: JsxToJson

1 点作者 talkingtab6 个月前
Collective Project: JsxToJson<p>Anyone interested in collectively creating and supporting an open source JavaScript project to parse Jsx into Json?<p>Why: I find it much easier to reason about and read Jsx instead of JSON. Yet JSON is a much better syntax for passing data around. Goal: Develop a small project which parses JSX and generates JSON.<p>``` &lt;Ducks sound=&quot;quack&quot;&gt; &lt;Fred color=&quot;green&quot; canfly=false &#x2F;&gt; &lt;Ducks&#x2F;&gt; ```<p>JsxToJson() should produce:<p>```{ &quot;Ducks&quot;: { &quot;sound&quot;: &quot;quack&quot;, &quot;children&quot;: [ { &quot;Fred&quot;: { &quot;color&quot;: &quot;green&quot;, &quot;canFly&quot;: false } } ] } } ```<p>I suspect, but do not know, that there are many uses for such a package.<p>And yes, there is For example, threejs uses a syntax that could easily be converted to JSON, which could (perhaps easily) be generated by Jsx. If you are interested, contact arthurgar nospace banzo@g also no space mail.com. Or if you already have something ...

1 comment

solardev6 个月前
I think the power of JSX is in being able to mix content with code and logic. You can have loops, maps, embedded ternaries, function calls, etc. It&#x27;s not all just static markup.<p>If you just want a data markup language... why not regular XML? Then you can easily parse it to JSON, e.g. <a href="https:&#x2F;&#x2F;codebeautify.org&#x2F;xmltojson&#x2F;y24f6a4c0" rel="nofollow">https:&#x2F;&#x2F;codebeautify.org&#x2F;xmltojson&#x2F;y24f6a4c0</a>