diff --git a/app/services/fetch_oembed_service.rb b/app/services/fetch_oembed_service.rb index c7d4f7e292..cc71a5f92b 100644 --- a/app/services/fetch_oembed_service.rb +++ b/app/services/fetch_oembed_service.rb @@ -86,14 +86,14 @@ class FetchOEmbedService end validate(parse_for_format(body)) if body.present? - rescue Oj::ParseError, Ox::ParseError + rescue JSON::ParserError, Ox::ParseError nil end def parse_for_format(body) case @format when :json - Oj.load(body, mode: :strict)&.with_indifferent_access + JSON.parse(body)&.with_indifferent_access when :xml Ox.load(body, mode: :hash_no_attrs)&.with_indifferent_access&.dig(:oembed) end diff --git a/lib/mastodon/cli/domains.rb b/lib/mastodon/cli/domains.rb index cbd3465e04..2b719f3777 100644 --- a/lib/mastodon/cli/domains.rb +++ b/lib/mastodon/cli/domains.rb @@ -140,13 +140,13 @@ module Mastodon::CLI Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res| next unless res.code == 200 - stats[domain] = Oj.load(res.to_s) + stats[domain] = JSON.parse(res.to_s) end Request.new(:get, "https://#{domain}/api/v1/instance/peers").perform do |res| next unless res.code == 200 - Oj.load(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer| + JSON.parse(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer| pool.post(peer, &work_unit) end end @@ -154,7 +154,7 @@ module Mastodon::CLI Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res| next unless res.code == 200 - stats[domain]['activity'] = Oj.load(res.to_s) + stats[domain]['activity'] = JSON.parse(res.to_s) end rescue failed.increment diff --git a/lib/tasks/emojis.rake b/lib/tasks/emojis.rake index 3b99a102d1..902c308739 100644 --- a/lib/tasks/emojis.rake +++ b/lib/tasks/emojis.rake @@ -109,7 +109,7 @@ namespace :emojis do emojis_light = 'đŸ‘ŊâšžđŸ”â˜ī¸đŸ’¨đŸ•Šī¸đŸ‘€đŸĨđŸ‘ģđŸâ•â”â›¸ī¸đŸŒŠī¸đŸ”ŠđŸ”‡đŸ“ƒđŸŒ§ī¸đŸđŸšđŸ™đŸ“đŸ‘đŸ’€â˜ ī¸đŸŒ¨ī¸đŸ”‰đŸ”ˆđŸ’ŦđŸ’­đŸđŸŗī¸âšĒâŦœâ—Ŋâ—ģī¸â–Ģī¸đŸĒŊđŸĒŋ' emojis_dark = '🎱🐜âšĢ🖤âŦ›â—ŧī¸â—žâ—ŧī¸âœ’ī¸â–Ēī¸đŸ’ŖđŸŽŗđŸ“ˇđŸ“¸â™Ŗī¸đŸ•ļī¸âœ´ī¸đŸ”ŒđŸ’‚â€â™€ī¸đŸ“Ŋī¸đŸŗđŸĻđŸ’‚đŸ”ĒđŸ•ŗī¸đŸ•šī¸đŸ•‹đŸ–Šī¸đŸ–‹ī¸đŸ’‚â€â™‚ī¸đŸŽ¤đŸŽ“đŸŽĨđŸŽŧâ™ ī¸đŸŽŠđŸĻƒđŸ“ŧ📹🎮🐃🏴🐞đŸ•ē📱📲🚲đŸĒŽđŸĻ‍âŦ›' - map = Oj.load(File.read(src)) + map = JSON.parse(File.read(src)) emojis_light.each_grapheme_cluster do |emoji| gen_border map[emoji], 'black' @@ -193,7 +193,7 @@ namespace :emojis do require 'vips' src = Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_data.json') - sheet = Oj.load(File.read(src)) + sheet = JSON.load_file(src) max = 0 sheet['emojis'].each_value do |row| diff --git a/lib/tasks/repo.rake b/lib/tasks/repo.rake index 6c696a9097..85c7bc43f3 100644 --- a/lib/tasks/repo.rake +++ b/lib/tasks/repo.rake @@ -22,7 +22,7 @@ namespace :repo do while url.present? response = HTTP.get(url) - contributors = Oj.load(response.body) + contributors = JSON.parse(response.body) contributors.each do |c| file << "* [#{c['login']}](#{c['html_url']})\n" if c['login'] @@ -68,7 +68,7 @@ namespace :repo do end end - pull_request = Oj.load(response.to_s) + pull_request = JSON.parse(response.to_s) pull_request['user']['login'] end diff --git a/lib/vite_ruby/sri_extensions.rb b/lib/vite_ruby/sri_extensions.rb index 31363272bf..edff6f808e 100644 --- a/lib/vite_ruby/sri_extensions.rb +++ b/lib/vite_ruby/sri_extensions.rb @@ -15,7 +15,7 @@ module ViteRuby::ManifestIntegrityExtension end def load_name_lookup_cache - Oj.load(config.build_output_dir.join('.vite/manifest-lookup.json').read) + JSON.load_file(config.build_output_dir.join('.vite/manifest-lookup.json')) end # Upstream's `virtual` type is a hack, re-implement it with efficient exact name lookup diff --git a/spec/lib/activitypub/activity/quote_request_spec.rb b/spec/lib/activitypub/activity/quote_request_spec.rb index d68f01211d..da46c22ce7 100644 --- a/spec/lib/activitypub/activity/quote_request_spec.rb +++ b/spec/lib/activitypub/activity/quote_request_spec.rb @@ -65,7 +65,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do expect { subject.perform } .to enqueue_sidekiq_job(ActivityPub::DeliveryWorker) .with(satisfying do |body| - outgoing_json = Oj.load(body) + outgoing_json = JSON.parse(body) outgoing_json['type'] == 'Reject' && %w(type id actor object instrument).all? { |key| json[key] == outgoing_json['object'][key] } end, recipient.id, sender.inbox_url) end @@ -78,7 +78,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do expect { subject.perform } .to enqueue_sidekiq_job(ActivityPub::DeliveryWorker) .with(satisfying do |body| - outgoing_json = Oj.load(body) + outgoing_json = JSON.parse(body) outgoing_json['type'] == 'Reject' && json['instrument']['id'] == outgoing_json['object']['instrument'] && %w(type id actor object).all? { |key| json[key] == outgoing_json['object'][key] } end, recipient.id, sender.inbox_url) end @@ -95,7 +95,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do .to change { quoted_post.reload.quotes.accepted.count }.by(1) .and enqueue_sidekiq_job(ActivityPub::DeliveryWorker) .with(satisfying do |body| - outgoing_json = Oj.load(body) + outgoing_json = JSON.parse(body) outgoing_json['type'] == 'Accept' && %w(type id actor object instrument).all? { |key| json[key] == outgoing_json['object'][key] } end, recipient.id, sender.inbox_url) end @@ -113,7 +113,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do .to change { quoted_post.reload.quotes.accepted.count }.by(1) .and enqueue_sidekiq_job(ActivityPub::DeliveryWorker) .with(satisfying do |body| - outgoing_json = Oj.load(body) + outgoing_json = JSON.parse(body) outgoing_json['type'] == 'Accept' && json['instrument']['id'] == outgoing_json['object']['instrument'] && %w(type id actor object).all? { |key| json[key] == outgoing_json['object'][key] } end, recipient.id, sender.inbox_url) end diff --git a/spec/requests/api/v1/donation_campaigns_spec.rb b/spec/requests/api/v1/donation_campaigns_spec.rb index 90add50820..762b7dbf20 100644 --- a/spec/requests/api/v1/donation_campaigns_spec.rb +++ b/spec/requests/api/v1/donation_campaigns_spec.rb @@ -109,7 +109,7 @@ RSpec.describe 'Donation campaigns' do expect(Rails.cache.read("donation_campaign_request:#{seed}:en", raw: true)) .to eq 'campaign-1:en' - expect(Oj.load(Rails.cache.read('donation_campaign:campaign-1:en', raw: true))) + expect(JSON.parse(Rails.cache.read('donation_campaign:campaign-1:en', raw: true))) .to match(campaign_json) end end diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 8279411a33..a7be815b2e 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -23,7 +23,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do ], } end - let(:json) { Oj.load(JSON.generate(payload)) } + let(:json) { JSON.parse(JSON.generate(payload)) } let(:alice) { Fabricate(:account) } let(:bob) { Fabricate(:account) } diff --git a/spec/support/streaming_client.rb b/spec/support/streaming_client.rb index c9a97ab060..005ddd922e 100644 --- a/spec/support/streaming_client.rb +++ b/spec/support/streaming_client.rb @@ -161,8 +161,8 @@ class StreamingClient def wait_for_message message = @connection.wait_for_event(:message) - event = Oj.load(message) - event['payload'] = Oj.load(event['payload']) if event['payload'] + event = JSON.parse(message) + event['payload'] = JSON.parse(event['payload']) if event['payload'] event.deep_symbolize_keys end