str_replace_all 関数を使用して、次の json で結合という用語を取り除こうとしています。正規表現をいくつか試しましたが、うまくいきませんでした。「ユニオン」の完全な文字列を取り除く方法に関する提案。これがコードです。
library(jsonlite)
json<- '{"open_issues":0,"union":{"avatar_url":"https://secure.gravatar.com/avatar/ed73cf7f24c091318e507d167c7b3456?d=https://a248.e.akamai.net/assets.mashups.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"ed73cf7f24c091318e507d167c7b3456","id":1556245,"login":"Toolpark","url":"https://api.mashups.com/users/Toolpark"},"owner":{"avatar_url":"https://secure.gravatar.com/avatar/ed73cf7f24c091318e507d167c7b3456?d=https://a248.e.akamai.net/assets.mashups.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"ed73cf7f24c091318e507d167c7b3456","id":1556245,"login":"Toolpark","url":"https://api.mashups.com/users/Toolpark"},"private":false,"pushed_at":"2012-07-12T11:43:31Z","size":964,"ssh_url":"vit@mashups.com:Toolpark/irma.vit","svn_url":"https://mashups.com/Toolpark/irma","updated_at":"2012-07-12T11:43:31Z","url":"https://api.mashups.com/repos/Toolpark/irma","watchers":2}'
str_replace_all(json,"union[^}]*}\s*, "")
json <- fromJSON(json)
Error: '\s' is an unrecognized escape in character string starting ""union[^}]*}\s"
最後にカンマを含むこの文字列を正確に取り除こうとしています:
"union":{"avatar_url":"https://secure.gravatar.com/avatar/ed73cf7f24c091318e507d167c7b3456?d=https://a248.e.akamai.net/assets.mashups.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png","gravatar_id":"ed73cf7f24c091318e507d167c7b3456","id":1556245,"login":"Toolpark","url":"https://api.mashups.com/users/Toolpark"},
助言がありますか?