abstract class Crest::ParamsEncoder


Custom serializers

You can build your custom encoder, if you like. The value of params_encoder can be any Crest::ParamsEncoder object that responds to: #encode(Hash) #=> String

The encoder will affect both how Crest processes query strings and how it serializes POST bodies.

The default encoder is Crest::FlatParamsEncoder.

Direct Known Subclasses

Defined in:


Class Method Summary

Instance Method Summary

Class Method Detail

def self.encode(params : Hash) : String #

[View source]
def self.flatten_params(object : JSON::Any, parent_key : String | Nil = nil) : Array(Tuple(String, Crest::ParamsValue)) #

Transform JSON::Any object into a flat array of {key, value}.

parent_key — Should not be passed (used for recursion)

params = JSON.parse(%({"access": [{"name": "mapping", "speed": "fast"}, {"name": "any", "speed": "slow"}]}))

# => [{"access[][name]", "mapping"}, {"access[][speed]", "fast"}, {"access[][name]", "any"}, {"access[][speed]", "slow"}]

# => [{"access[1][name]", "mapping"}, {"access[1][speed]", "fast"}, {"access[2][name]", "any"}, {"access[2][speed]", "slow"}]

[View source]

Instance Method Detail

abstract def encode(params : Hash) : String #

[View source]