Needs example with curl
coolaj86 opened this issue · comments
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.
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!
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.
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.
Way awesome job, btw.
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!
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.
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:
Line 233 in a0e08cb
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.