本文整理汇总了C#中LitJson.JsonWriter类的典型用法代码示例。如果您正苦于以下问题:C# JsonWriter类的具体用法?C# JsonWriter怎么用?C# JsonWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonWriter类属于LitJson命名空间,在下文中一共展示了JsonWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createResource
public static void createResource()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
DirectoryInfo di = new DirectoryInfo(Global.PATH + "/res");
var jd = new LitJson.JsonData();
FileInfo[] fs = di.GetFiles("*", SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in fs)
{
if (fi.Name.Contains(".manifest"))
{
continue;
}
string pPath = "res/" + fi.Name;
jd[pPath.Replace("/", "@").Replace("\\", "@")] = pPath;
}
getJsonData(jd,"");
JsonWriter writer = new JsonWriter(sb);
writer.PrettyPrint = true;
writer.IndentValue = 4;
jd.ToJson(writer);
string result = CoccosHelper.Properties.Resources.tpl.Replace("#1#", sb.ToString());
File.WriteAllText(Global.PATH + "/src/resource.js", result);
}
示例2: Encode
public string Encode(object obj)
{
JsonWriter writer = new JsonWriter();
JsonMapper.ToJson(obj, writer);
return writer.ToString();
}
示例3: Write
static void Write(JsonWriter writer, string failedMessage)
{
WriteObject(writer, () =>
{
WriteProperty(writer, "message", failedMessage);
});
}
示例4: ExportJson
public override void ExportJson(JsonWriter writer)
{
using (var scope = new JsonScopeObjectWriter(writer)) {
WriteCommonObjectNode(writer, scope);
scope.WriteKeyValue("color", Color);
scope.WriteKeyValue("intensity", Intensity);
}
}
示例5: ExportJson
public override void ExportJson(JsonWriter writer)
{
using (var scope = new JsonScopeObjectWriter(writer)) {
WriteCommonObjectNode(writer, scope);
scope.WriteKeyValue("geometry", Geometry.Uuid);
scope.WriteKeyValue("material", Material.Uuid);
}
}
示例6: ErrorPropertyExpectedTest
public void ErrorPropertyExpectedTest ()
{
JsonWriter writer = new JsonWriter ();
writer.WriteObjectStart ();
writer.Write (10);
writer.WriteObjectEnd ();
}
示例7: ExportJson
public override void ExportJson(JsonWriter writer)
{
using (var scope = new JsonScopeObjectWriter(writer)) {
scope.WriteKeyValue("url", "./" + Name);
scope.WriteKeyValue("uuid", Uuid);
scope.WriteKeyValue("name", Name);
}
}
示例8: ErrorArrayClosingTest
public void ErrorArrayClosingTest()
{
JsonWriter writer = new JsonWriter ();
writer.WriteArrayStart ();
writer.Write (true);
writer.WriteObjectEnd ();
}
示例9: LitJsonWriterObjects
public static void LitJsonWriterObjects ()
{
for (int j = 0; j < Common.Iterations; j++) {
StringBuilder output = new StringBuilder ();
JsonWriter writer = new JsonWriter (new StringWriter (output));
int n = Common.SampleObject.Length;
for (int i = 0; i < n; i += 2) {
switch ((char) Common.SampleObject[i]) {
case '{':
writer.WriteObjectStart ();
break;
case '}':
writer.WriteObjectEnd ();
break;
case '[':
writer.WriteArrayStart ();
break;
case ']':
writer.WriteArrayEnd ();
break;
case 'P':
writer.WritePropertyName (
(string) Common.SampleObject[i + 1]);
break;
case 'I':
writer.Write (
(int) Common.SampleObject[i + 1]);
break;
case 'D':
writer.Write (
(double) Common.SampleObject[i + 1]);
break;
case 'S':
writer.Write (
(string) Common.SampleObject[i + 1]);
break;
case 'B':
writer.Write (
(bool) Common.SampleObject[i + 1]);
break;
case 'N':
writer.Write (null);
break;
}
}
}
}
示例10: ErrorExcessDataTest
public void ErrorExcessDataTest()
{
JsonWriter writer = new JsonWriter ();
writer.WriteArrayStart ();
writer.Write (true);
writer.WriteArrayEnd ();
writer.Write (false);
}
示例11: SaveSettings
public void SaveSettings(Settings.SerializedForm serializedForm) {
JsonWriter writer = new JsonWriter();
writer.PrettyPrint = true;
JsonMapper.ToJson(serializedForm, writer);
string json = writer.ToString();
StreamWriter sr = new StreamWriter(this.configFile);
sr.Write(json);
sr.Close();
}
示例12: SaveTasks
public void SaveTasks(TaskList.SerializedForm serializedForm) {
JsonWriter writer = new JsonWriter();
writer.PrettyPrint = true;
JsonMapper.ToJson(serializedForm, writer);
string json = writer.ToString();
StreamWriter sr = new StreamWriter(this.taskFile);
sr.Write(json);
sr.Close();
}
示例13: ErrorObjectClosingTest
public void ErrorObjectClosingTest()
{
JsonWriter writer = new JsonWriter ();
writer.WriteObjectStart ();
writer.WritePropertyName ("foo");
writer.Write ("bar");
writer.WriteArrayEnd ();
}
示例14: ToNetMsg
public static void ToNetMsg(Dictionary<long, F3_NetServerInfo> servers, ref NetOutgoingMessage netMsg)
{
netMsg.Write((byte)NetDataType.eDATA_REQUEST_SERVER_LIST);
StringBuilder sb = new StringBuilder();
JsonWriter writer = new JsonWriter(sb);
writer.WriteObjectStart();
writer.WritePropertyName("servers");
writer.WriteArrayStart();
for (int i = 0; i < servers.Count; i++)
{
F3_NetServerInfo info = servers.ElementAt(i).Value;
writer.WriteObjectStart();
writer.WritePropertyName("UUID");
writer.Write(servers.ElementAt(i).Key);
writer.WritePropertyName("serverName");
writer.Write(info.m_serverName);
writer.WritePropertyName("type");
writer.Write((int)info.m_serverType);
writer.WritePropertyName("internal_ip");
writer.Write(info.m_serverInternalAdress.Address.ToString());
writer.WritePropertyName("internal_port");
writer.Write(info.m_serverInternalAdress.Port);
writer.WritePropertyName("external_ip");
writer.Write(info.m_serverExternalAdress.Address.ToString());
writer.WritePropertyName("external_port");
writer.Write(info.m_serverExternalAdress.Port);
writer.WritePropertyName("maxPlayers");
writer.Write(info.m_maxPlayers);
writer.WritePropertyName("currentPlayers");
writer.Write(info.m_currentNbPlayers);
writer.WritePropertyName("token");
writer.Write(info.m_NATtoken);
writer.WriteObjectEnd();
}
writer.WriteArrayEnd();
writer.WriteObjectEnd();
netMsg.Write(sb.ToString());
}
开发者ID:SharpEdgeEntertainment,项目名称:FrozenFlameFramework,代码行数:54,代码来源:F3.+NetMessageRequestServerList.cs
示例15: BooleansTest
public void BooleansTest()
{
JsonWriter writer = new JsonWriter ();
writer.WriteArrayStart ();
writer.Write (true);
writer.Write (false);
writer.Write (false);
writer.Write (true);
writer.WriteArrayEnd ();
}