Skip to content

A tasty little treat that turns your objects into query strings. (a.k.a. Objects baked into a URLs)

License

Notifications You must be signed in to change notification settings

ChrisMissal/Quiche

Repository files navigation

Quiche logo

How to Use Quiche

It's crazy simple to get started, take the following code for example:

var builder = new Builder();
var obj = new MixedObject
	{
		ItemNames = new[] { "one", "two" },
		TextMessage = "programming is fun"
	};
var result = builder.ToQueryString(obj);

result.ShouldBe("?ItemNames=one&ItemNames=two&TextMessage=programming+is+fun");

Field Casing Options

Not a fan of Pascal Casing? You can use Camel Case as well.

var settings = new BuilderSettings { FieldCasing = FieldCasing.CamelCase };
var builder = new Builder(settings);
var result = builder.ToQueryString(new MixedObject { ItemNames = new[] { "one", "two" }, TextMessage = "programming is fun" });

result.ShouldBe("?itemNames=one&itemNames=two&textMessage=programming+is+fun");

Field Array Options

You can override the default formatting of Arrays if you need.

var builder = new Builder(x =>
{
    x.FieldArray = FieldArray.UseArraySyntax;
});
var result = builder.ToQueryString(new { cars = new[] { "Saab", "Audi", "Nissan", "Ford" } });

result.ShouldBe("?cars[]=Saab&cars[]=Audi&cars[]=Nissan&cars[]=Ford");
var builder = new Builder(x =>
{
    x.FieldArray = FieldArray.UseCommas;
});
var result = builder.ToQueryString(new { cars = new[] { "Saab", "Audi", "Nissan", "Ford" } });

result.ShouldBe("?cars=Saab%2cAudi%2cNissan%2cFord");

Custom Converter

Maybe Pascal or Camel casing isn't enough for you. You can transform your fields using a custom function like so:

var builder = new Builder(x =>
{
    x.CustomFieldConverter = s => s.ToUpper();
});
var result = builder.ToQueryString(new { Test = "blah" });

result.ShouldBe("?TEST=blah");

Build Status

chrismissal MyGet Build Status

Features

Version 0.1.0

Contributors

License

The MIT License Copyright (c) 2014 Chris Missal

About

A tasty little treat that turns your objects into query strings. (a.k.a. Objects baked into a URLs)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published