Fetches data from anywhere(or atleast strives to) and converts it to JSON.
should convert csv to json.
anyToJSON.csv({path: "test/100.csv"}, function(data){
var output = [{"a":"4","b":"9","c":"2","d":"3"}];
var anyToJSONdata = data;
assert.equal(JSON.stringify(anyToJSONdata), JSON.stringify(output));
done()
});
should not break when there are commas in strings.
anyToJSON.csv({path: "test/test.csv"}, function(data){
var output = [{"Id":"1","UserName":"Sam, Smith"},
{"Id":"2","UserName":"Fred Frankly"},
{"Id":"1","UserName":"Zachary Zupers"}];
anyToJSONdata = data;
assert.equal(JSON.stringify(anyToJSONdata), JSON.stringify(output));
done();
})
should load json from a file.
anyToJSON.json({path: "test/test.json"}, function(data){
var output = [{"a":"4","b":"9","c":"2","d":"3"}];
anyToJSONdata = data;
assert.equal(JSON.stringify(anyToJSONdata), JSON.stringify(output));
done()
});
should load json from rest.
server.startServer(function(){
anyToJSON.restJSON({
hostname: "localhost",
port: 3000,
path: "/json"},function(data){
var output = [{"a":"4","b":"9","c":"2","d":"3"}];
var anyToJSONdata = data;
assert.equal(JSON.stringify(anyToJSONdata), JSON.stringify(output));
done();
})
});
should load csv from rest.
server.startServer(function(){
anyToJSON.restCSV({
hostname:"localhost",
port: 3000,
path: "/csv"}, function(data){
anyToJSONdata = data;
var output = [{"a":"4","b":"9","c":"2","d":"3"}]
assert.equal(JSON.stringify(anyToJSONdata), JSON.stringify(output));
done();
})
})
- CSV flat file
- JSON flat file
- CSV REST API
- JSON REST API
- Databases (ODBC support)
- Support for XML
- Support for Streaming data