Git Product home page Git Product logo

Comments (8)

 avatar commented on July 29, 2024 1

Here is another one.

How do I extract the keys from a data structure?

jq

echo '{"source": "./", "dest": "~/"}' | jq 'keys'

nu (as of 0.41.0)

echo '{"source": "./", "dest": "~/"}' | from json | get

from nushell.github.io.

 avatar commented on July 29, 2024 1

@Shackelford-Arden thanks for fiddling a solution!

Perhaps a new directory in https://github.com/nushell/nu_scripts could house some of these idioms.

from nushell.github.io.

dogancelik avatar dogancelik commented on July 29, 2024

I have one example here: Download all tarballs of an NPM package

from nushell.github.io.

 avatar commented on July 29, 2024

I imagine those examples should live in https://github.com/nushell/nu_scripts. Then a writer could author a tutorial referencing those high-quality sources.

from nushell.github.io.

 avatar commented on July 29, 2024

Another example I came across: how do I delete a key from a JSON value?
Consider programmatically removing a development dependency from a package.json.
Using jq:

jq 'del(.devDependencies.husky)' < package.json

For nu I wasn't sure how to do this. open package.json | update devDependencies and then what 😄 ?

from nushell.github.io.

sophiajt avatar sophiajt commented on July 29, 2024

@efx - the current way seems to be:

open Cargo.toml | update dev-dependencies { echo $it.dev-dependencies | reject ansi_term }

But I think we could make reject take in a path, so you could reject something deeper in the table.

from nushell.github.io.

 avatar commented on July 29, 2024

@jonathandturner thank you! I'll add that to my ever expanding nu knowledge.

from nushell.github.io.

Shackelford-Arden avatar Shackelford-Arden commented on July 29, 2024

@efx Happened upon this and thought that I'd note that your example using 0.41.0 doesn't seem to work anymore (running 0.68.1 here).

Running what you have above using 0.68.1 I get the following:

image

I played around a bit though and while not as elegant as jq 'keys' it does give similar results:

echo '{"source": "./", "dest": "~/"}' | from json | transpose | get column0

image

from nushell.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.