Skip to content

IPAddr#to_json remove prefix address with CIDR #503

Closed as not planned
Closed as not planned

Description

@taketo1113

IPAddr#to_json removed the prefix address with IPAddr/CIDR value.
It unable to deserialize IPAddr/CIDR value.

Expected behavior

require 'date'
require 'json'

IPAddr.new('172.16.0.0/24').to_json #=> "\"172.16.0.0/24\""

Actual behavior

require 'ipaddr'
require 'json'

IPAddr.new('172.16.0.0/24').to_json #=> "\"172.16.0.0\""

Related URL

Activity

  1. added a commit that references this issue on Dec 3, 2022
  2. byroot commented on Oct 17, 2024

    @byroot
    Member

    The JSON gem has no specific support for IpAddr. I suspect this is a change in IpAddr#to_s which is what JSON call when it doesn't know about a particular type.

  3. taketo1113 commented on Oct 18, 2024

    @taketo1113
    Author

    Thanks to reply.

    The JSON gem has no specific support for IpAddr.

    I will create PR to add IPAddr#to_json method in ipaddr gem.
    Becase I think the changing behavior of IPAddr#to_s has breaking compatibility.

    see. rails/rails#52365

  4. taketo1113 commented on Oct 18, 2024

    @taketo1113
    Author

    cc: @byroot
    I have created PR to add IPAddr#to_json/as_json for ipaddr gem.
    ruby/ipaddr#77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions