4

I am trying to read this data into R with Jsonlite:

"{\"Transaction\": [{\"RetailStoreID\":\"2005\",\"WorkstationID\":\"1\",\"SequenceNumber\":6944,\"Items\":[\"2017-12-04T16:10:32\"],\"ItemsElementName\":[\"BeginDateTime\"],\"OperatorID\":{\"Value\":\"15668\"},\"OperatorLogonID\":{\"Value\":\"15668\"},\"CurrencyCode\":\"DKK\",\"TlogName\":\"1162.tlg\",\"TlogOffset\":\"1095151\",\"FREEDOM_WorkstationType\":\"IS2\",\"Items1\":[{\"TillID\":\"1\",\"RevenueCenterID\":\"FAKTA\",\"ReceiptDateTime\":\"2017-12-04T16:10:32\",\"FREEDOM_TransactionEndCalloutOffline\":false,\"LineItem\":[{\"SequenceNumber\":4,\"Item\":{\"Items\":[{\"POSItemID\":\"5701049015356\"},{\"Level\":\"Department\",\"Text\":[\"999\"]}],\"ItemsElementName\":[\"POSIdentity\",\"MerchandiseHierarchy\"],\"Description\":\"K"

But I get the error:

parse error: premature EOF.

My code looks like this:

g<-readLines(file("poslog.json"), warn=FALSE,skipNul = TRUE)
json_df<-fromJSON(g,simplifyVector = TRUE)

Any hints? Thanks.

storaged
  • 1,837
  • 20
  • 34
Soren
  • 53
  • 1
  • 4
  • 1
    Is that really your raw data or output from printing a line in the R console? – hrbrmstr Dec 13 '17 at 11:02
  • printing from line R console – Soren Dec 13 '17 at 17:21
  • we need the raw data OR you need to `cat()` the data to the console OR use `print(quote=FALSE, …)` so we can be sure we're seeing the actual bytes vs any mangling R did to show the strings to you. – hrbrmstr Dec 13 '17 at 19:28
  • Thanks. When I use cat() the output I get: {"Transaction":[{"RetailStoreID":"2005","WorkstationID":"1","SequenceNumber":6944,"Items":["2017-12-04T16:10:32"],"ItemsElementName":["BeginDateTime"],"OperatorID":{"Value":"15668"},"OperatorLogonID":{"Value":"15668"},"CurrencyCode":"DKK","TlogName":"1162.tlg","TlogOffset":"1095151","FREEDOM_WorkstationType":"IS2","Items1":[{"TillID":"1","RevenueCenterID":"FAKTA","ReceiptDateTime":"2017-12-04T16:10:32","FREEDOM_TransactionEndCalloutOffline":false,"LineItem":[{"SequenceNumber":4,"Item" – Soren Dec 14 '17 at 09:00

0 Answers0