本文整理汇总了C#中Jayrock.Json.JsonTextWriter类的典型用法代码示例。如果您正苦于以下问题:C# JsonTextWriter类的具体用法?C# JsonTextWriter怎么用?C# JsonTextWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonTextWriter类属于Jayrock.Json命名空间,在下文中一共展示了JsonTextWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "application/json";
string programID = Request.QueryString["programID"];
string recordOption = Request.QueryString["option"];
bool success;
if (User.IsInRole("recorder"))
{
success = uWiMP.TVServer.Recordings.RecordProgramById(Convert.ToInt32(programID), (Recordings.RecordingType)Convert.ToInt32(recordOption));
}
else
{
success = false;
}
using (JsonTextWriter jw = new JsonTextWriter())
{
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("result");
jw.WriteBoolean(success);
jw.WriteEndObject();
Response.Write(jw.ToString());
}
}
示例2: ConvertRequestToJson
static internal string ConvertRequestToJson(uWiMP.TVServer.MPClient.Request request)
{
JsonTextWriter jw = new JsonTextWriter();
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("action");
jw.WriteString(request.Action);
jw.WriteMember("filter");
jw.WriteString(request.Filter);
jw.WriteMember("value");
jw.WriteString(request.Value);
jw.WriteMember("start");
jw.WriteString(request.Start.ToString());
jw.WriteMember("pagesize");
jw.WriteString(request.PageSize.ToString());
jw.WriteMember("shuffle");
jw.WriteBoolean(request.Shuffle);
jw.WriteMember("enqueue");
jw.WriteBoolean(request.Enqueue);
jw.WriteMember("tracks");
jw.WriteString(request.Tracks);
jw.WriteEndObject();
return jw.ToString();
}
示例3: Page_Load
protected void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "application/json";
string programID = Request.QueryString["programID"];
Program program = uWiMP.TVServer.Programs.GetProgramByProgramId(Convert.ToInt32(programID));
Channel channel = uWiMP.TVServer.Channels.GetChannelByChannelId(program.IdChannel);
string timetext = string.Format("<b>{0}-{1}</b><br>", program.StartTime.ToShortTimeString(), program.EndTime.ToShortTimeString());
string title = program.Title == "" ? GetGlobalResourceObject("uWiMPStrings", "unknown_title").ToString() : program.Title;
string episodeName = program.EpisodeName == "" ? timetext : timetext + "<b>" + program.EpisodeName + "</b><br>";
string description = program.Description == "" ? GetGlobalResourceObject("uWiMPStrings", "description_not_found").ToString() : episodeName + program.Description;
using (JsonTextWriter jw = new JsonTextWriter())
{
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("title");
jw.WriteString(title);
jw.WriteMember("description");
jw.WriteString(description);
jw.WriteMember("channel");
jw.WriteString(channel.DisplayName);
jw.WriteMember("running");
jw.WriteBoolean(program.IsRunningAt(DateTime.Now));
jw.WriteMember("scheduled");
jw.WriteBoolean(uWiMP.TVServer.Schedules.IsProgramScheduled(program));
jw.WriteEndObject();
Response.Write(jw.ToString());
}
}
示例4: Complex
public void Complex()
{
const string input = @"{'menu': {
'header': 'SVG Viewer',
'items': [
{'id': 'Open'},
{'id': 'OpenNew', 'label': 'Open New'},
null,
{'id': 'ZoomIn', 'label': 'Zoom In'},
{'id': 'ZoomOut', 'label': 'Zoom Out'},
{'id': 'OriginalView', 'label': 'Original View'},
null,
{'id': 'Quality'},
{'id': 'Pause'},
{'id': 'Mute'},
null,
{'id': 'Find', 'label': 'Find...'},
{'id': 'FindAgain', 'label': 'Find Again'},
{'id': 'Copy'},
{'id': 'CopyAgain', 'label': 'Copy Again'},
{'id': 'CopySVG', 'label': 'Copy SVG'},
{'id': 'ViewSVG', 'label': 'View SVG'},
{'id': 'ViewSource', 'label': 'View Source'},
{'id': 'SaveAs', 'label': 'Save As'},
null,
{'id': 'Help'},
{'id': 'About', 'label': 'About Adobe CVG Viewer...'}
]
}}";
JsonTextReader reader = new JsonTextReader(new StringReader(input));
JsonTextWriter writer = new JsonTextWriter();
JsonRecorder.Record(reader).Playback(writer);
Assert.AreEqual("{\"menu\":{\"header\":\"SVG Viewer\",\"items\":[{\"id\":\"Open\"},{\"id\":\"OpenNew\",\"label\":\"Open New\"},null,{\"id\":\"ZoomIn\",\"label\":\"Zoom In\"},{\"id\":\"ZoomOut\",\"label\":\"Zoom Out\"},{\"id\":\"OriginalView\",\"label\":\"Original View\"},null,{\"id\":\"Quality\"},{\"id\":\"Pause\"},{\"id\":\"Mute\"},null,{\"id\":\"Find\",\"label\":\"Find...\"},{\"id\":\"FindAgain\",\"label\":\"Find Again\"},{\"id\":\"Copy\"},{\"id\":\"CopyAgain\",\"label\":\"Copy Again\"},{\"id\":\"CopySVG\",\"label\":\"Copy SVG\"},{\"id\":\"ViewSVG\",\"label\":\"View SVG\"},{\"id\":\"ViewSource\",\"label\":\"View Source\"},{\"id\":\"SaveAs\",\"label\":\"Save As\"},null,{\"id\":\"Help\"},{\"id\":\"About\",\"label\":\"About Adobe CVG Viewer...\"}]}}", writer.ToString());
}
示例5: String
public void String()
{
JsonRecorder recorder = new JsonRecorder();
recorder.WriteString("Hello World");
JsonTextWriter writer = new JsonTextWriter();
recorder.Playback(writer);
Assert.AreEqual("\"Hello World\"", writer.ToString());
}
示例6: JayrockWriterObjects
public static void JayrockWriterObjects ()
{
for (int j = 0; j < Common.Iterations; j++) {
StringBuilder output = new StringBuilder ();
JsonWriter writer = new JsonTextWriter (new StringWriter (output));
int n = Common.SampleObject.Length;
for (int i = 0; i < n; i += 2) {
switch ((char) Common.SampleObject[i]) {
case '{':
writer.WriteStartObject ();
break;
case '}':
writer.WriteEndObject ();
break;
case '[':
writer.WriteStartArray ();
break;
case ']':
writer.WriteEndArray ();
break;
case 'P':
writer.WriteMember (
(string) Common.SampleObject[i + 1]);
break;
case 'I':
writer.WriteNumber (
(int) Common.SampleObject[i + 1]);
break;
case 'D':
writer.WriteNumber (
(double) Common.SampleObject[i + 1]);
break;
case 'S':
writer.WriteString (
(string) Common.SampleObject[i + 1]);
break;
case 'B':
writer.WriteBoolean (
(bool) Common.SampleObject[i + 1]);
break;
case 'N':
writer.WriteNull ();
break;
}
}
}
}
示例7: WriteBoolean
public void WriteBoolean()
{
JsonTextWriter writer = new JsonTextWriter(new StringWriter());
writer.WriteBoolean(true);
Assert.AreEqual("true", writer.ToString());
writer = new JsonTextWriter(new StringWriter());
writer.WriteBoolean(false);
Assert.AreEqual("false", writer.ToString());
}
示例8: Write
public static void Write(Geometry geometry, TextWriter writer)
{
if (geometry == null)
return;
if (writer == null)
throw new ArgumentNullException("writer", "A valid text writer object is required.");
JsonTextWriter jwriter = new JsonTextWriter(writer);
Write(geometry, jwriter);
}
示例9: ReturnBoolean
static internal string ReturnBoolean(bool value)
{
JsonTextWriter jw = new JsonTextWriter();
jw.PrettyPrint = true;
jw.WriteStartObject();
jw.WriteMember("result");
jw.WriteBoolean(value);
jw.WriteEndObject();
return jw.ToString();
}
示例10: PrettyColorPrint
private static void PrettyColorPrint(string path, TextWriter output, JsonPalette palette)
{
Debug.Assert(output != null);
using (TextReader input = path.Equals("-") ? Console.In : new StreamReader(path))
using (JsonTextReader reader = new JsonTextReader(input))
using (JsonTextWriter writer = new JsonTextWriter(output))
{
writer.PrettyPrint = true;
JsonColorWriter colorWriter = new JsonColorWriter(writer, palette);
colorWriter.WriteFromReader(reader);
output.WriteLine();
}
}
示例11: PretifyJson
public static string PretifyJson(this string text)
{
var input = new StringReader(text);
var output = new StringWriter();
using (var reader = new JsonTextReader(input))
using (var writer = new JsonTextWriter(output))
{
writer.PrettyPrint = true;
writer.WriteFromReader(reader);
}
return output.ToString();
}
示例12: JayrockWriterNumbers
public static void JayrockWriterNumbers ()
{
for (int i = 0; i < Common.Iterations; i++) {
StringBuilder output = new StringBuilder ();
JsonWriter writer = new JsonTextWriter (new StringWriter (output));
writer.WriteStartArray ();
foreach (int n in Common.SampleInts)
writer.WriteNumber (n);
foreach (double n in Common.SampleDoubles)
writer.WriteNumber (n);
writer.WriteEndArray ();
}
}
示例13: PrettyPrinting
public void PrettyPrinting()
{
JsonTextWriter writer = new JsonTextWriter();
writer.PrettyPrint = true;
writer.WriteFromReader(new JsonTextReader(new StringReader("{'menu':{'id':'file','value':'File:','popup':{'menuitem':[{'value':'New','onclick':'CreateNewDoc()'},{'value':'Open','onclick':'OpenDoc()'},{'value':'Close','onclick':'CloseDoc()'}]}}}")));
Assert.AreEqual(RewriteLines(@"{
""menu"": {
""id"": ""file"",
""value"": ""File:"",
""popup"": {
""menuitem"": [ {
""value"": ""New"",
""onclick"": ""CreateNewDoc()""
}, {
""value"": ""Open"",
""onclick"": ""OpenDoc()""
}, {
""value"": ""Close"",
""onclick"": ""CloseDoc()""
} ]
}
}
}"), writer.ToString() + Environment.NewLine);
}
示例14: Authenticate
internal bool Authenticate()
{
Jayrock.Json.JsonTextWriter jsonWriter = new Jayrock.Json.JsonTextWriter();
jsonWriter.WriteStartObject();
jsonWriter.WriteMember("version");
jsonWriter.WriteNumber(1);
jsonWriter.WriteMember("topic");
jsonWriter.WriteString("contact-center");
jsonWriter.WriteMember("request-id");
jsonWriter.WriteNumber(GetUniqueReqID());
jsonWriter.WriteMember("message");
jsonWriter.WriteString("authenticate");
jsonWriter.WriteMember("user");
jsonWriter.WriteString(strAdapterUserName);
jsonWriter.WriteMember("password");
jsonWriter.WriteString(strAdapterPassword);
jsonWriter.WriteEndObject();
if (!SendRequest(jsonWriter.ToString()))
return false;
return ReceiveResponse("authenticate");
}
示例15: CreateJsonWriter
private static JsonWriter CreateJsonWriter(TextWriter writer)
{
JsonTextWriter jsonWriter = new JsonTextWriter(writer);
jsonWriter.PrettyPrint = true;
return jsonWriter;
}