Skip to content

Instantly share code, notes, and snippets.

@alastairs alastairs/Json.cs
Created Apr 10, 2015

Embed
What would you like to do?
A simple type to wrap up a JSON string into an object that represents the concept of "a JSON string". Use this anywhere you want have to say "string" but really want to say "JSON".
using System;
namespace RedGate.Cef.WebUI.Impl
{
/// <summary>
/// A simple type to wrap up a JSON string into an object that represents the concept of a JSON string.
/// Use this anywhere you have to say "string" but really want to say "JSON".
/// </summary>
[Serializable]
public class Json
{
private readonly string m_WrappedString;
private Json(string jsonString)
{
m_WrappedString = jsonString;
}
public override string ToString()
{
return m_WrappedString;
}
public static implicit operator string(Json json)
{
return json.ToString();
}
public static implicit operator Json(string jsonString)
{
return new Json(jsonString);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.