TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Jolt – JSON to JSON transformation

108 pointsby bencevansover 8 years ago

16 comments

fiatjafover 8 years ago
I see this is a Java library, but if you&#x27;re in the command line (or even if you are able to call an external process for the job) jq[1] is great.<p>[1]: <a href="https:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;manual&#x2F;" rel="nofollow">https:&#x2F;&#x2F;stedolan.github.io&#x2F;jq&#x2F;manual&#x2F;</a>
评论 #13025401 未加载
评论 #13026494 未加载
评论 #13024019 未加载
JayOtterover 8 years ago
The idea of supplying a spec to transform arbitrary data is interesting to me. I did one in JavaScript called Reshaper[1], and then hooked it up to a library wrapper called Smolder[2].<p>The result was a sort of system whereby data going into a function would be automatically &#x27;reshaped&#x27;. It worked well as a proof-of-concept, but obviously was too fragile for most uses (though it&#x27;s used in the automatic graphs in Kajero[3]). The difference here seems to be that the spec defines the actual transformations, rather than just the desired final structure.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;reshaper" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;reshaper</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;smolder" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;smolder</a> [3] <a href="https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;kajero" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joelotter&#x2F;kajero</a>
评论 #13024409 未加载
plumaover 8 years ago
This seems like something that would lend itself to not tying itself to any specific implementation, yet it seems to be entirely based on a particular Java implementation.<p>It would probably be more useful if it more explicitly tied itself to the Java implementation (i.e. stop pretending to be its own thing) or were more abstract to be worth implementing in other languages.<p>In the latter case it&#x27;d be helpful if the operations were part of the actual unified DSL instead of having a DSL for each transformation (with the implication that each transformation is applied individually?).<p>EDIT: But if you abstract this away from Java, why not just use JSON Patch: <a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc6902" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc6902</a>
评论 #13023201 未加载
zevebover 8 years ago
<i>sigh</i>, can we <i>please</i> just stop re-implementing S-expressions and Lisp, and instead just use S-expressions and Lisp?<p>It&#x27;s like I&#x27;m the only one using electric lighting while all the hipsters are upgrading their wax-dipped hemp brands to artisan whale oil …
mozeyover 8 years ago
I&#x27;ve used template libs to do this in the past, e.g. mustache.js, handlebars.js, Jinja2, etc. Then generating JSON as output instead of HTML. Usually quick to learn the template libraries DSL, and I find templates easier to read than transforms.
loliveover 8 years ago
Some food for thought:<p>JSON format+JSON.parse() make you loose the graph structure of the data you have on your server and that you send to the client. Because it is basically a tree structure.<p>The Semantic Web defines a graph description langage called N3. If your server can serialize and send the data in such a format, and if you use the function N3.parse() on your client, you eventually retrieve, on the client, a graph of in-memory objects that corresponds to the data graph on your server. You can then traverse that graph in any direction you want.<p>So basically, with N3, you never lose the graph structure of your data.<p>And you do not need to restructure your JSON.
评论 #13023472 未加载
评论 #13023448 未加载
评论 #13024074 未加载
评论 #13024101 未加载
intrasightover 8 years ago
In .Net-land, I&#x27;ve switched to doing this type of thing in Linq. But if you like XSLT (I still do), you can do it in three lines of code. 1. Convert JSON to XML 2. Run XSLT 3. Convert XML to JSON
评论 #13025284 未加载
dr3sover 8 years ago
Interesting but with no mention of json patch in the alternatives. I&#x27;m not sure why this project would be better.
评论 #13023279 未加载
lobster_johnsonover 8 years ago
Related&#x2F;shameless plug: We&#x27;ve been working on a reimagining of JSONPath [1] which we hope will be useful to other people.<p>Unfortunately, it&#x27;s not public yet — though we have working libraries in JavaScript and Go (a heavily modified fork of Kubernetes&#x27; JSONPath code) we intend to release — mostly because we want to publish a proper spec. In fact, we&#x27;re looking for a good name for it, as we feel that releasing &quot;JSONPath 2.0&quot; would be a little presumptious. I was thinking something like JSONMatch. If there&#x27;s sufficient interest I could prioritize it (email me!).<p>Our own version of JSONPath is intended for both searching and patching documents in general. A simple search would be something like:<p><pre><code> friends[name == &#x27;bob&#x27;].id </code></pre> or<p><pre><code> shoppingItems[1:3][description, id] </code></pre> We use this to declaratively extract data from documents, but also change it. The patching support lets you do things like:<p><pre><code> match(document, &quot;..[role == &#x27;owner&#x27;].role&quot;) .set(&#x27;admin&#x27;); </code></pre> This will set &quot;role&quot;. It gets rather magical and beautiful when you have multiple paths that involve unions, subindexed arrays and constraints.<p>We also have a separate patch notation, expressed in JSON, to declaratively transform documents. It uses these JSONPaths to select and set values. We might write a spec for that, too, although I&#x27;m not sure the utility outside our app is that great.<p>[1] <a href="http:&#x2F;&#x2F;goessner.net&#x2F;articles&#x2F;JsonPath&#x2F;" rel="nofollow">http:&#x2F;&#x2F;goessner.net&#x2F;articles&#x2F;JsonPath&#x2F;</a>
jonafover 8 years ago
The readme is more up-to-date than GitHub pages. It answers some of the questions in the comments. <a href="https:&#x2F;&#x2F;github.com&#x2F;bazaarvoice&#x2F;jolt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bazaarvoice&#x2F;jolt</a>
anilgulechaover 8 years ago
This is an interesting take on schemas in json. Is the big advantage that this provides additional data validation (on top of type validation?) Can there be custom transforms written in javascript?
otabdeveloper1over 8 years ago
Are we _really_ going to reinvent all the spectacularly bad ideas of XML, except this time in JSON?
评论 #13022363 未加载
评论 #13022731 未加载
评论 #13022021 未加载
评论 #13022934 未加载
评论 #13022014 未加载
评论 #13022066 未加载
fiatjafover 8 years ago
Seems enormously complicated. Is this &quot;cool&quot; in Java-land?
评论 #13021952 未加载
oweilerover 8 years ago
This is much easier to do with Groovy.
评论 #13023111 未加载
评论 #13022789 未加载
legulereover 8 years ago
The website stutters here with safari when scrolling, making reading the site a bad experience.
Vinkekattenover 8 years ago
Well wy not go all the way there? It&#x27;s just a matter of time. Here&#x27;s the manual.<p><a href="http:&#x2F;&#x2F;www.wrox.com&#x2F;WileyCDA&#x2F;WroxTitle&#x2F;XSLT-2-0-and-XPath-2-0-Programmer-s-Reference-4th-Edition.productCd-0470192747.html" rel="nofollow">http:&#x2F;&#x2F;www.wrox.com&#x2F;WileyCDA&#x2F;WroxTitle&#x2F;XSLT-2-0-and-XPath-2-...</a>