Hi Community,
I would like to remove trailing and leading quotes from a character vector and later on convert to json object.
In this case when I use noquote() function with toJSON() from jsonlite package, an error is returned as Error: No method asJSON S3 class: noquote
Example code is below
#> character vector
reproducibile_users_invite <-c("{\"firstName\":\"Emmanuel\",\"surname\":\"Emmanuel2\",\"email\":\"Emmanuel@email.com\",\"userCredentials\":{\"username\":\"EEmmanuel2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"dataViewOrganisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}",
"{\"firstName\":\"Grant\",\"surname\":\"Grant2\",\"email\":\"Grant@email.com\",\"userCredentials\":{\"username\":\"GGrant2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"dataViewOrganisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}",
"{\"firstName\":\"Patience\",\"surname\":\"Patience2\",\"email\":\"Patience@email.com\",\"userCredentials\":{\"username\":\"PPatience2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"dataViewOrganisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}",
"{\"firstName\":\"Thomas\",\"surname\":\"Thomas2\",\"email\":\"Thomas@email.com\",\"userCredentials\":{\"username\":\"TThomas2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"dataViewOrganisationUnits\":[{\"id\":\"LndFoMpqBfp\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}",
"{\"firstName\":\"Andrew\",\"surname\":\"Andrew2\",\"email\":\"Andrew@email.com\",\"userCredentials\":{\"username\":\"AAndrew2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"nDd4i6SPeth\"}],\"dataViewOrganisationUnits\":[{\"id\":\"nDd4i6SPeth\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}",
"{\"firstName\":\"Nicholas\",\"surname\":\"Nicholas2\",\"email\":\"Nicholas@email.com\",\"userCredentials\":{\"username\":\"NNicholas2\",\"userRoles\":[{\"id\":\"cBCK2qrYxyv\"}],\"catDimensionConstraints\":[{\"id\":\"MnQamDMlY87\"}]},\"organisationUnits\":[{\"id\":\"nDd4i6SPeth\"}],\"dataViewOrganisationUnits\":[{\"id\":\"nDd4i6SPeth\"}],\"userGroups\":[{\"id\":\"MA3AsjoPf3o\"}]}"
)
jsonlite::toJSON(list(users=noquote(reproducibile_users_invite)),auto_unbox=TRUE)
#> Error: No method asJSON S3 class: noquote