Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Needs example with curl #8

Closed
coolaj86 opened this Issue Dec 10, 2011 · 7 comments

Comments

Projects
None yet
2 participants
Contributor

coolaj86 commented Dec 10, 2011

How would I parse RESPONSE in this working example?

RESPONSE=`curl --silent 'http://foobar3000.com/echo/request.json'`
echo ${RESPONSE}

Will you please put the example for this in your README?

P.S. http://foobar3000.com and http://helloworld3000.com are a public echo servers I put up for just these sorts of occasions.

Owner

kristopolous commented Dec 10, 2011

Well it's more of a JIT than a run-time compiler TBH, so I'm tempted to think it may be out-of-scope. But since Bash is perfectly capable of reflection and the runtime still has hooks to the compiler, it should be quite doable ... Let me think about it over the weekend. Thanks for the interest!

@ghost ghost assigned kristopolous Dec 10, 2011

Owner

kristopolous commented Dec 10, 2011

ok, I've thought about it ... I could pull it off with a function call ... I've written it and it seems to work. Do you have any suggestions on the name? I was thinking something like "tickEval" or "tickImport" or "tickParse" or something like that ... I want to make sure I pick the right semantics; api choices are very important.

Contributor

coolaj86 commented Dec 10, 2011

JavaScript:

JSON.parse

Ruby:

JSON.parse or JSON.decode

Python:

json.loads

I like tickParse because you're parsing it into an object. decode and load make sense in the context of marshaling / deserializing, but Bash JSON Parser sounds better than a Bash JSON decoder or Bash JSON Loader.

Contributor

coolaj86 commented Dec 10, 2011

Way awesome job, btw.

Owner

kristopolous commented Dec 10, 2011

Alright great. I'm working (cough cough for pay) right now ... but I'll be able to get back to this thing tonight. Thanks for the ideas!

coolaj86 added a commit to coolaj86/TickTick that referenced this issue Dec 10, 2011

Contributor

coolaj86 commented Dec 10, 2011

Ignore my typo in that pull request, should have been 8.

In return for your work on the example I'll plaster plugs for this in at least 5 different places on stackoverflow asking about JSON parsing in bash for which this would be the solution. I have my tabs open and ready.

Owner

kristopolous commented Dec 12, 2011

Fixed as of a0e08cb

Synopsis:

There were a number of issues here, from having bare variable references, to hyphens in the names. They all had to be addressed and were taken care of.

The added function is as we have discussed, tickParse and is implemented here:

tickParse() {
.

It's a simple hack based on the existing system.

The "test.sh" has been renamed "Example.sh" and a tests folder has been created. This tests folder has the json file from the example you gave along with a file named "runtime.sh" which essentially does what you asked for but does so locally, so that it can be ran without relying necessarily on the network or your server.

This commit also closes issue 10 which was opened to explain the only core change that was done here.

Thanks for your interest again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment