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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Introducing TJSON: Tagged JSON with Rich Types

36 点作者 alexatkeplar大约 8 年前

16 条评论

portlander12345大约 8 年前
Surprised no one here has mentioned Transit. It&#x27;s an extensible typed data format with both JSON and binary representations. In other words, you can configure custom types, such as Immutable data structures, and they&#x27;ll be automatically serialized and restored for you.<p>Good intro: <a href="http:&#x2F;&#x2F;cognitect.github.io&#x2F;transit-tour&#x2F;" rel="nofollow">http:&#x2F;&#x2F;cognitect.github.io&#x2F;transit-tour&#x2F;</a><p>GitHub: <a href="https:&#x2F;&#x2F;github.com&#x2F;cognitect&#x2F;transit-js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cognitect&#x2F;transit-js</a><p>Note that in the introduction they provide a simple benchmark where Transit is both more compact and faster to parse than JSON with custom hydration.
keithwhor大约 8 年前
Biggest complaint:<p>Unreadable format, as mentioned in this thread.<p>{&quot;key:A&lt;A&lt;s&gt;&gt;&quot;:[[&quot;values&quot;],[&quot;here&quot;]]}<p>This doesn&#x27;t mean anything to me as a developer, unless I&#x27;ve seen the spec. It&#x27;s kludgy. It&#x27;s not reverse-compatible if you don&#x27;t install a TJSON parser.<p>Two solutions immediately strike me as better, one has been mentioned here.<p>(1) Not optimal, but <i>actually spell out words</i> in key names. There&#x27;s no reason &quot;A&quot; has to mean Array. That doesn&#x27;t mean anything to me. If I&#x27;m seeing it for the first time and have no idea what TJSON is, the very next value could be &quot;key2:B&lt;B&lt;t&gt;&gt;&quot;.<p>(2) Far more optimal: as an example has been provided with &quot;date&quot;, just nest objects as values for any extended types. Then this spec is <i>completely</i> reverse compatible and compliant, and as a developer I don&#x27;t have to worry about parsing key names.<p>e.g.<p><pre><code> { &quot;some_nested_array&quot;: { &quot;type&quot;: &quot;array.array.string&quot;, &quot;value&quot;: [ [&quot;values&quot;], [&quot;here&quot;] ] } } </code></pre> Extremely easy to implement and not reliant on a governing body.
评论 #14196665 未加载
tobltobs大约 8 年前
Dear JS Hipsters, even if you all suffer from NIHS, could you please take look at XML before you invent another format. I am sure you will get used to those square brackets.
评论 #14196381 未加载
评论 #14195770 未加载
评论 #14197871 未加载
评论 #14195487 未加载
laurent123456大约 8 年前
I&#x27;m curious what would be the use case for this? JSON is a human readable&#x2F;writable format, however this kind of syntax is not anymore: &quot;{&quot;nested-array:A&lt;A&lt;s&gt;&gt;&quot;: [[&quot;Nested&quot;], [&quot;Array!&quot;]]}&quot;<p>So it feels more like a machine format, but in that case why not use a more efficient one, like a binary format?
评论 #14195063 未加载
评论 #14195032 未加载
评论 #14195028 未加载
hajile大约 8 年前
If you&#x27;re making it unreadable with types, you might as well switch to a statically typed binary JSON format like bson or ubjson instead. You get smaller files, faster parsing, partial parsing (skip what you don&#x27;t need), and (in some implementations) streaming of large files.<p><a href="http:&#x2F;&#x2F;ubjson.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;ubjson.org&#x2F;</a><p><a href="http:&#x2F;&#x2F;bsonspec.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;bsonspec.org&#x2F;</a>
escherize大约 8 年前
Edn seems like a better solution here. Not o ly is the tagging more straightforward (wow not embedded in a string?), But you can write your own tags for custom types.
user5994461大约 8 年前
If you want JSON with type checking, use a json schema.<p><a href="http:&#x2F;&#x2F;json-schema.org&#x2F;examples.html" rel="nofollow">http:&#x2F;&#x2F;json-schema.org&#x2F;examples.html</a><p>Been there for almost a decade. Already supported by all the major json libraries in all the major languages.
ungzd大约 8 年前
This is literally hungarian notation for JSON.
dolmen大约 8 年前
As any normal JSON document is not a valid TJSON document (and worse, some JSON document may be valid TJSON documents but TJSON imposes a different interpretation) using the &quot;JSON&quot; suffix is just misleading.
pfooti大约 8 年前
literally the only use case I see here is dates. Like everything else I can infer the type of the field based on its contents. &quot;boolean&quot;: false, no kidding. &quot;event_ts&quot;: 1223349483, is that an index number or milliseconds since epoch or what? Well, probably ms since epoch, but my one gripe about json is that there&#x27;s no good way to push dates without domain knowledge (anything whose property name ends in _at or _ts gets converted? all numbers in a certain range get converted?)
评论 #14195161 未加载
dep_b大约 8 年前
Backward compatibility seems terrible to me. A regular JSON parser will produce garbage from this since variable names are changed while an XML parser parsing without any context how to parse specific fields will still provide correct data. Your dates might remain strings for example but the string is still correct.
TazeTSchnitzel大约 8 年前
I question the value of the tags where they state the obvious. Does this<p><pre><code> {&quot;foo:O&quot;:{}} </code></pre> really tell you more than<p><pre><code> {&quot;foo&quot;:{}} </code></pre> ?<p>The ability to encode sets, integers, binary data and time stamps is useful. But why tag things which are what they look like? It&#x27;s a waste of space.
评论 #14204655 未加载
zwerdlds大约 8 年前
Anyone care to give a first blush comparison vs protobuffs&#x2F;json schema?
评论 #14195600 未加载
panic大约 8 年前
Some previous discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12856968" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12856968</a>
keredson大约 8 年前
Why would you define the type of something in the PARENT object?
评论 #14196267 未加载
Entangled大约 8 年前
I prefer YAML no matter how much lipstick you put on JSON.
评论 #14201205 未加载