Skip to content

Add ignore and ignore_deserialize properties to URI::Params::Field #16873

Description

@Fijxu

Feature Request

JSON::Serializable and YAML::Serializable contain this field properties to ignore serialization/deserialization, URI::Params::Serializable could also have them to use them with something like this (crystal spec):

struct A
  include URI::Params::Serializable

  property name : String
  property age : Int32?

  def initialize(@name : String, @age : Int32? = nil)
    after_initialize
  end

  @[URI::Params::Field(ignore: true)]
  property msg : String?

  def after_initialize
    @msg = "Hello " + name
  end
end

person = A.new("Vasya", 30)
person.msg.should eq "Hello Vasya"

person.to_www_form.should eq "name=Vasya&Age=30"

A.from_www_form(person.to_www_form).msg.should eq "Hello Vasya"

Currently, with that small spec code, A.from_www_form(person.to_www_form).msg.should eq "Hello Vasya" will actually equal to "name=Vasya&age=30&msg=Hello+Vasya" since property @msg is not ignored.


Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueThis is an issue suited for newcomers to become aquianted with working on the codebase.help wantedThis issue is generally accepted and needs someone to pick it upkind:featuretopic:stdlib:serialization

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions