I am having a heck of a time reading the following JSON into an R dataframe from a text file called "D:/myjsonShort" on Windows 10. I have tried using the RJSONIO
,jsonlite
, and rjson
packages with the fromJSON functions, but can't seem to read this in. I want to read this so that my data frame will contain variables: "volumne", "timestamp", "high", "low", 'etc.
[{u'volume': u'0', u'timestamp': Decimal('0'), u'high': u'0', u'low': u'0', u'quoteVolume': u'0', u'close': u'0', u'weightedAverage': u'0', u'open': u'0', u'market': u'POLO-BTC_REP'},
{u'volume': u'0.02202444', u'timestamp': Decimal('1494050400'), u'high': u'0.01101223', u'low': u'0.01101222', u'quoteVolume': u'2', u'close': u'0.01101223', u'weightedAverage': u'0.01101222', u'open': u'0.01101222', u'market': u'POLO-BTC_REP'},
{u'volume': u'0.00363405', u'timestamp': Decimal('1494050700'), u'high': u'0.0110123', u'low': u'0.0110123', u'quoteVolume': u'0.33', u'close': u'0.0110123', u'weightedAverage': u'0.0110123', u'open': u'0.0110123', u'market': u'POLO-BTC_REP'}]
Here is some code I tried, but this just ends up returning an empty list of strings:
library(RJSONIO)
a<-fromJSON("D:/myjsonShort.txt")
a
and this returns:
[[1]]
[[1]]$`'volume`
NULL
[[1]]$`'timestamp`
NULL
[[1]]$`'high`
NULL
[[1]]$`'low`
NULL
[[1]]$`'quoteVolume`
NULL
[[1]]$`'close`
NULL
[[1]]$`'weightedAverage`
NULL
[[1]]$`'open`
NULL
[[1]]$`'market`
NULL
[[2]]
[[2]]$`'volume`
NULL
[[2]]$`'timestamp`
NULL
[[2]]$`'high`
NULL
[[2]]$`'low`
NULL
[[2]]$`'quoteVolume`
NULL
[[2]]$`'close`
NULL
[[2]]$`'weightedAverage`
NULL
[[2]]$`'open`
NULL
[[2]]$`'market`
NULL
[[3]]
[[3]]$`'volume`
NULL
[[3]]$`'timestamp`
NULL
[[3]]$`'high`
NULL
[[3]]$`'low`
NULL
[[3]]$`'quoteVolume`
NULL
[[3]]$`'close`
NULL
[[3]]$`'weightedAverage`
NULL
[[3]]$`'open`
NULL
[[3]]$`'market`
NULL
Any ideas how to fix this?