neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

[Implementation] Better JSON creator #5

Open ColinFay opened 6 years ago

ColinFay commented 6 years ago

For now the way the JSON api call is kind of a hack, there must be a way to code it a better way.

I need to write something that looks exactly like :

{
  "statements" : [ {
    "statement" : "CREATE (n) RETURN id(n)"
  } ]
}

For now I'm doing :

to_json_neo <- function(query, include_stats, meta, type){
  toJSON(list(statement = query, includeStats = include_stats, meta = meta, resultDataContents = list(type)), auto_unbox = TRUE)
}

query_jsonised <- to_json_neo(query_clean, include_stats, meta, type)

body <- glue('{"statements" : [ %query_jsonised% ]}', .open = "%", .close = "%")