protected override string stringifyValue(int indentLevel, JSONStringifyOptions options) { var t = new StringBuilder(); bool hasItemsInList = false; t.Append(CHAR_START); foreach (object valueItem in value) { if (hasItemsInList) { t.Append(CHAR_ITEM_SEPARATOR); } if (options.lineFeedOnArrays) { t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel + 1)); } else { t.Append(options.arrayAfterSeparator); } t.Append(JSONEncoder.encode(valueItem, indentLevel + 1, options)); hasItemsInList = true; } t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel)); t.Append(CHAR_END); return(t.ToString()); }
protected override string stringifyValue(int indentLevel, JSONStringifyOptions options) { var t = new StringBuilder(); bool hasItemsInList = false; t.Append(CHAR_START); foreach (KeyValuePair <string, object> valueItem in value) { if (hasItemsInList) { t.Append(CHAR_ITEM_SEPARATOR); } t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel + 1)); t.Append(JSONEncoder.encode(valueItem.Key, 0, options)); t.Append(options.objectAfterKey + CHAR_KEY_SEPARATOR + options.objectBeforeValue); t.Append(JSONEncoder.encode(valueItem.Value, indentLevel + 1, options)); hasItemsInList = true; } t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel)); t.Append(CHAR_END); return(t.ToString()); }
public void ConfirmCapture() { JSONObject payload = JSONEncoder.EncodeCapture(SelectedUnit, TargetedObjective); MatchManager.instance.SendAction("capture_objective", payload); EndCapture(); }
public void ConfirmAttack() { JSONObject data = JSONEncoder.EncodeAttack(SelectedUnit, TargetTiles); MatchManager.instance.SendAction("basic_attack", data); Debug.Log(data); EndAttack(); }
public void ConfirmMove() { JSONObject data = JSONEncoder.EncodeMove(selectedUnit, Path); MatchManager.instance.SendAction("move", data); Debug.Log(data); EndMove(); ConfirmPanel.Hide(); }
protected override void Content() { _popupWindow.OnGUI(); CustomEventGUI(); ParamsGUI(); GUILayout.Label(JSONEncoder.Encode(_eventParameters)); }
private void OnGUI() { popupWindow.onGUI(); GUI.contentColor = Color.black; onCustomEventGUI(); onParamsGUI(); if (Button("Back To Main Scene")) { SceneManager.LoadScene("MainScene"); } GUILayout.Label(JSONEncoder.Encode(eventParameters)); }
public void PushAttribution(Dictionary <string, object> conversionData, string attributionSource, string conversionUid) { var data = JSONEncoder.Encode(conversionData); Debug.Log($"PushAttribution: data:{data}, attributionSource: {attributionSource}, conversionUid:{conversionUid}"); int provider; switch (attributionSource) { default: provider = 0; break; } _QonvPushAttribution(data, provider, conversionUid); }
public void TestArrayOfEventsJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var message = MessageHelper.CreateFromStream(TestHelper.GetTestStream("ArrayOfEvents.xml")); var output = pipeline.Execute(message); var retStr = MessageHelper.ReadString(output); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); }
public void TestEmptyRootNodeJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var message = MessageHelper.CreateFromStream(TestHelper.GetTestStream("EmptyEvents.xml")); var output = pipeline.Execute(message); var stream = new StreamReader(output.BodyPart.GetOriginalDataStream(), Encoding.UTF8); var retStr = stream.ReadToEnd(); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); }
private void ParamsGUI() { _key = GUILayout.TextField(_key); _value = GUILayout.TextField(_value); Button("Add error environment", () => { _errorEnvironment[_key] = _value; AppMetrica.Instance.PutErrorEnvironmentValue(_key, _value); }); Button("Clear error environment", () => { foreach (string key in _errorEnvironment.Keys) { AppMetrica.Instance.PutErrorEnvironmentValue(key, null); } _errorEnvironment.Clear(); }); GUILayout.Label(JSONEncoder.Encode(_errorEnvironment)); }
public void TestLargeFileJSONEncoder() { var pipeline = PipelineFactory.CreateEmptySendPipeline(); var component = new JSONEncoder { ArrayOutput = true, RemoveOuterEnvelope = true }; pipeline.AddComponent(component, PipelineStage.Encode); var doc = new XmlDocument(); var stream = TestHelper.GetTestStream("large.xml"); doc.Load(stream); stream.Seek(0, SeekOrigin.Begin); var message = MessageHelper.CreateFromStream(stream); var output = pipeline.Execute(message); var retStr = MessageHelper.ReadString(output); var JsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(retStr); Assert.IsTrue(JsonObj is Newtonsoft.Json.Linq.JArray); Assert.AreEqual(doc.DocumentElement.ChildNodes.Count, (JsonObj as Newtonsoft.Json.Linq.JArray).Count); }
private static string CreateCommand(string descriptorJson) { JObject desc = JSONDecoder.Decode(descriptorJson); // Item name if (!desc.ObjectValue.ContainsKey("name")) { throw new DescriptorException("Item 'name' was not found. Make sure your current document has a valid item descriptor in it."); } string name = desc["name"].StringValue; // Item count int count = 1; if (desc.ObjectValue.ContainsKey("count")) { count = (int)desc["count"]; } // Base command StringBuilder command = new StringBuilder(); command.AppendFormat("/spawnitem {0} {1}", name, count); // Item Parameters if (desc.ObjectValue.ContainsKey("parameters")) { JObject parameters = desc["parameters"]; string sParameters = JSONEncoder.Encode(parameters); // Add parameters to command command.AppendFormat(" '{0}'", sParameters.Replace("'", "\\'")); } return(command.ToString()); }
private static string EncodeObject(object obj) { return(JSONEncoder.Encode(obj)); }
public static string stringify(IList input, bool prettyPrint = false) { return(JSONEncoder.encode(input, prettyPrint)); }
public static string stringify(IDictionary input, bool prettyPrint = false) // TODO: prettyPrint should be false by default... but it conflicts with the string version { return(JSONEncoder.encode(input, prettyPrint)); }
/// <summary> /// Converts the model's properties to a JSON-encoded string. /// </summary> /// <returns></returns> public virtual string toJSON() { return(JSONEncoder.Encode(this.preparePropertiesForSimpleJSON())); }
private string JsonStringFromDictionary(IDictionary dictionary) { return((dictionary != null) ? JSONEncoder.Encode(dictionary) : null); }
public static string stringify(bool input) { return(JSONEncoder.encode(input, false)); }
private static string JsonStringFromDictionary(IEnumerable dictionary) { return(dictionary == null ? null : JSONEncoder.Encode(dictionary)); }