Skip to content

Instantly share code, notes, and snippets.

@wactbprot
Created May 12, 2011 22:12
Show Gist options
  • Save wactbprot/969579 to your computer and use it in GitHub Desktop.
Save wactbprot/969579 to your computer and use it in GitHub Desktop.
library(RJSONIO, quietly =TRUE)
goOn <- TRUE
while(goOn){
jIn <- scan('stdin',
'',
n=1,
quiet=TRUE,
sep="\n")
## 4 debuging purposes one can:
## save(a,file="wactbprot/a.oo", ascii=TRUE)
##
rIn <- fromJSON(jIn)
## try catch stuff needed here
query <- rIn$query
if(length(query$do) == 1){
switch(query$do,
this = rOut <- list(reply="this done"),
that = rOut <- list(reply="that done")
)
}else{
rOut <- list(reply="nothing done")
}
jOut <- gsub("\n","",toJSON(rOut))
cat(paste("{ \"code\":200,\"json\":",jOut,"}\n" ,sep=""))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment