I have a josn file I'm working with that contains multiple json objects in a single file. R is unable to read the file as a whole. But since each object occurs at regular intervals, I would like to iteratively read a fixed number of lines into R. 

There are a number of SO questions on reading single lines into R but I have been unable to extend these solutions to a fixed number of lines. For my problem I need to read 16 lines into R at a time (eg 1-16, 17-32 etc)

I have tried using a loop but can't seem to get the syntax right: 

```
## File
file <- "results.json"

## Create connection
con <- file(description=file, open="r")

## Loop over a file connection
for(i in 1:1000) {
  tmp <- scan(file=con, nlines=16, quiet=TRUE)
  data[i] <- fromJSON(tmp)
}

```

The file contains over 1000 objects of this form:

```
{
  "object": [
    [
      "a",
      0
    ],
    [
      "b",
      2
    ],
    [
      "c",
      2
    ]
  ]
}

```
['https://Stackoverflow.com/questions/34831973', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4530884/']
```
SELECT t.Id, t.Info, 
    -- this works in SQL Server
    CAST ((CASE WHEN r.UserId IS NOT NULL THEN 1 ELSE 0 END) AS BIT) AS IsRegistered 
FROM Tournaments as t
   LEFT JOIN Registrations as r ON t.Id = r.TournamentId
where (r.UserId = '' OR r.UserId = @user)

```

-- i think this one is help for you...
You should clarify what SQL language you are actually using, but an answer can be provided anyway:

```
CREATE PROCEDURE [dbo].[TournamentsWithLoggedUser]
    @user nvarchar(128)
AS
BEGIN
    SELECT t.Id, t.Info, 
        -- this works in SQL Server
        CAST ((CASE WHEN r.UserId IS NOT NULL THEN 1 ELSE 0 END) AS BIT) AS IsRegistered 
    FROM Tournaments as t
       LEFT JOIN Registrations as r ON t.Id = r.TournamentId
    where r.UserId IS NULL OR r.UserId = @user

    -- this should not be required
    RETURN

```

END

However, there is a problem with the logic:

`@user` is not nullable, so your procedure gives the impression that it looks data for a single user. However, your OR operator allows to select all records from unregistered users united with the record for the particular provided user (if exists).