Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Needs example with curl #8

Closed
coolaj86 opened this Issue · 7 comments

2 participants

AJ ONeal Chris McKenzie
AJ ONeal

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.

Chris McKenzie

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!

Chris McKenzie kristopolous was assigned
Chris McKenzie

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.

AJ ONeal

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.

AJ ONeal

Way awesome job, btw.

Chris McKenzie

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!

AJ ONeal coolaj86 referenced this issue from a commit in coolaj86/TickTick
AJ ONeal coolaj86 [ISSUE #8] added Apache License 2, stated in README cb62ebe
AJ ONeal

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.

Chris McKenzie

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: https://github.com/kristopolous/TickTick/blob/a0e08cb2d6d820b9c8aec768fb6ed5e8fca563f5/ticktick.sh#L233 .

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
Something went wrong with that request. Please try again.