A tasty little treat that turns your objects into query strings. (a.k.a. Objects baked into a URLs)
C# JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets/logo
docs
src
.gitattributes
.gitignore
documentup.min.js
gulp-msbuild.js
gulp-quiche-features.js
gulpfile.js
index.html
license.txt
readme.md

readme.md

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