本文整理汇总了C#中JSONNode类的典型用法代码示例。如果您正苦于以下问题:C# JSONNode类的具体用法?C# JSONNode怎么用?C# JSONNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONNode类属于命名空间,在下文中一共展示了JSONNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseJson
/**
* Parse json response from blockscan
* call asset's function if same name asset are found in json response
* */
public void ParseJson(JSONNode jsonResponse)
{
//check if asset has been found at this address (bad format address?)
if (jsonResponse == null) {
Debug.Log ("no asset found at this address");
return;
}
Debug.Log ("jsonReponse text: " + jsonResponse.ToString ());
Debug.Log ("jsonResponse data count: " + jsonResponse ["data"].Count);
//store number of asset found in json response
int nbrOfAsset = jsonResponse ["data"].Count;
//iterate to check if asset name are the same in assetName array and asset from json response
for (int i = 0; i < nbrOfAsset; i++) {
for (int y = 0; y < assetName.Length; y++){
if (jsonResponse ["data"] [i] ["asset"].Value == assetName[y]){
string methodName = "Asset"+i;
//Get the method information using the method info class
MethodInfo mi = this.GetType().GetMethod(methodName);
//Invoke the method Asset1, Asset2, etc..
var arguments = new object[] { y };
mi.Invoke(this, arguments);
}
}
Debug.Log ("asset name: " + jsonResponse ["data"] [i] ["asset"].Value);
Debug.Log ("asset balance: " + jsonResponse ["data"] [i] ["balance"].Value);
}
}
开发者ID:Joul1285,项目名称:UnityDecentralizedAsset,代码行数:36,代码来源:BlockscanCheckAsset.cs
示例2: parseJSONStats
private Stats parseJSONStats(JSONNode stats)
{
Teaching t = new Teaching(stats["teaching"][0].AsInt, stats["teaching"][1].AsInt,stats["teaching"][2].AsInt,stats["teaching"][3].AsInt,stats["teaching"][4].AsInt);
Combat c = new Combat(stats["combat"][0].AsInt,stats["combat"][1].AsInt,stats["combat"][2].AsInt,stats["combat"][3].AsInt,stats["combat"][4].AsInt);
Intelligence i = new Intelligence(stats["intelligence"][0].AsInt,stats["intelligence"][1].AsInt,stats["intelligence"][2].AsInt,stats["intelligence"][3].AsInt,stats["intelligence"][4].AsInt);
return new Stats(t, c, i);
}
开发者ID:barykade,项目名称:SupervillainColonyLeader,代码行数:7,代码来源:LoadFiles.cs
示例3: RegionData
public RegionData(JSONNode N) {
RegionPolicies = new Dictionary<string, PolicyData>();
countryList = new Dictionary<string, CountryData>();
gridSquares = new List<int>();
recoveryFunding = 10;
spriteLocation = N["picture"];
name = N["name"];
agentCount = N["personnel"]["agentCount"].AsInt;
responseTeamCount = N["personnel"]["responseTeamCount"].AsInt;
agentEffectiveness = N["personnel"]["agentEffectiveness"].AsFloat;
responseTeamEffectiveness = N["personnel"]["responseTeamEffectiveness"].AsFloat;
regionPicture = Resources.Load<Sprite>(N["picture"]);
abilityName = N["ability"]["name"];
abilityDesc = N["ability"]["desc"];
if (N["policies"] != null) {
foreach (JSONNode policy in N["policies"].Children)
RegionPolicies.Add(policy["name"], new PolicyData(policy.ToString()));
}
//Problem is past this point?
foreach (JSONNode country in N["countries"].AsArray)
countryList.Add (country["name"], new CountryData(country));
gridSquares = GameUtils.ParseIntList(N["gridSquares"]);
}
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:26,代码来源:RegionData.cs
示例4: Save
public void Save(ref JSONNode N) {
N["TrueHQ"] = TrueHQ.ToString();
N["regionNum"] = Location.regionCode.ToString();
N["statusCode"] = Location.statusCode.ToString();
N["gridNum"] = Location.gridCell.ToString();
N["spawnLocation"] = Location.spawnLocation.ToString();
}
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:7,代码来源:GOIHQBase.cs
示例5: Start
// Use this for initialization
void Start () {
Messenger.AddListener<float>("Simulate Activity", UpdateEvents);
Messenger.AddListener<SCPData>("New SCP Loaded", AddSCPEvent);
if (redHerringJson == null)
{
//Read event data from system files.
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, redHerringEventFileName + ".txt");
redHerringJson = JSONNode.Parse(System.IO.File.ReadAllText(filePath));
filePath = System.IO.Path.Combine(Application.streamingAssetsPath, anomalousEventFileName + ".txt");
anomalousEventJson = JSONNode.Parse(System.IO.File.ReadAllText(filePath));
filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "flavorMarquee.txt");
flavorMarqueeJson = JSONNode.Parse(System.IO.File.ReadAllText(filePath));
}
EventList = new Dictionary<int, AnomalousEvent>();
if (GlobalPlayerData.preLoadedData != null && !GlobalPlayerData.preLoadedData.Equals(""))
{
Load(GlobalPlayerData.preLoadedData["AnomalousEventManager"]);
} else
{
StepsSinceLastSpawn = 0;
StepsUntilNextSpawn = 0;
IDGenerator = 0;
}
}
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:28,代码来源:AnomalousEventManager.cs
示例6: CountryData
public CountryData(JSONNode N) {
cityList = new List<CityData>();
gridSquares = new List<int>();
name = N["name"];
foundationRelationship = 5;
fundingLevel = 0;
fundingMultiplier = N["fundingMultiplier"].AsFloat;
militaryMultiplier = N["militaryMultiplier"].AsFloat;
population = N["population"].AsInt;
if (N["picture"] != null) {
spriteLocation = N["picture"];
countryPicture = Resources.Load<Sprite>(spriteLocation);
}
//remove this check once data is complete
if (N["gridSquares"] != null)
gridSquares = GameUtils.ParseIntList(N["gridSquares"]);
if (N["cities"] != null) {
foreach (JSONNode city in N["cities"].AsArray) {
cityList.Add(new CityData(city));
}
}
}
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:25,代码来源:CountryData.cs
示例7: LevelTarget
public LevelTarget(JSONNode json)
{
switch (json["limit_type"])
{
case "Time":
LimitType = LimitType.Time;
TimeSpan = json["limit"].AsInt;
break;
case "Moves":
LimitType = LimitType.Moves;
Moves = json["limit"].AsInt;
break;
}
StarsLevels = new List<int>();
for (var i = 0; i < json["stars_levels"].AsArray.Count; i++)
{
StarsLevels.Add(json["stars_levels"][i].AsInt);
}
_prices = new List<KeyValuePair<int, int>>();
for (int i = 0; i < json["prices"].AsArray.Count; i++)
{
KeyValuePair<int, int> pair =
new KeyValuePair<int, int>(json["prices"][i]["index"].AsInt, json["prices"][i]["price"].AsInt);
_prices.Add(pair);
}
}
开发者ID:arahis,项目名称:Swiper,代码行数:28,代码来源:BlockPrices.cs
示例8: AddCurveIngredients
public static void AddCurveIngredients(JSONNode ingredientDictionary, string prefix)
{
//in case there is curveN, grab the data if more than 4 points
//use the given PDB for the representation.
var numCurves = ingredientDictionary["nbCurve"].AsInt;
var curveIngredientName = prefix + "_" + ingredientDictionary["name"].Value;
var pdbName = ingredientDictionary["source"]["pdb"].Value.Replace(".pdb", "");
SceneManager.Instance.AddCurveIngredient(curveIngredientName, pdbName);
for (int i = 0; i < numCurves; i++)
{
//if (i < nCurve-10) continue;
var controlPoints = new List<Vector4>();
if (ingredientDictionary["curve" + i.ToString()].Count < 4) continue;
for (int k = 0; k < ingredientDictionary["curve" + i.ToString()].Count; k++)
{
var p = ingredientDictionary["curve" + i.ToString()][k];
controlPoints.Add(new Vector4(-p[0].AsFloat, p[1].AsFloat, p[2].AsFloat, 1));
}
SceneManager.Instance.AddCurve(curveIngredientName, controlPoints);
//break;
}
Debug.Log("*****");
Debug.Log("Added curve ingredient: " + curveIngredientName);
Debug.Log("Num curves: " + numCurves);
}
开发者ID:matmuze,项目名称:VIZZIES,代码行数:30,代码来源:CellPackLoader.cs
示例9: WriteToStream
public void WriteToStream(JSONNode pNode, Stream s)
{
using (textWriter = new StreamWriter(s))
{
WriteToStream(pNode, textWriter);
}
}
开发者ID:substans,项目名称:JohJSON,代码行数:7,代码来源:JSONNodeWriter.cs
示例10: Level
public Level(JSONNode docLevel)
{
initRooms(docLevel["rooms"]);
initPositions(docLevel["positions"]);
initLinks(docLevel["links"]);
initPlayer(docLevel["player"]);
}
开发者ID:xDaizu,项目名称:gamejam2015,代码行数:7,代码来源:Level.cs
示例11: assess
public IEnumerator assess(string p_action, JSONNode p_values, Action<JSONNode> callback)
{
print("--- assess action (" + p_action + ") ---");
string putDataString =
"{" +
"\"action\": \"" + p_action + "\"" +
", \"values\": " + p_values.ToString() +
"}";
string URL = baseURL + "/gameplay/" + idGameplay + "/assessAndScore";
WWW www = new WWW(URL, Encoding.UTF8.GetBytes(putDataString), headers);
// wait for the requst to finish
yield return www;
JSONNode returnAssess = JSON.Parse(www.text);
feedback = returnAssess["feedback"].AsArray;
scores = returnAssess["scores"].AsArray;
print("Action " + putDataString + " assessed! returned: " + returnAssess.ToString());
foreach (JSONNode f in feedback)
{
// log badge
if (string.Equals(f["type"], "BADGE"))
{
badgesWon.Add(f);
}
}
callback(returnAssess);
}
开发者ID:dantay0803,项目名称:SystemBuilder,代码行数:33,代码来源:EngAGe.cs
示例12: ApplyData
void ApplyData(JSONNode masterJSON)
{
Debug.Log("Appling Data from JSON");
SetTitle(masterJSON[0]);
SetMaxObjects(masterJSON[1]);
SetButtonData(masterJSON[2]);
}
开发者ID:Xellos1010,项目名称:JSONPullAndUITest,代码行数:7,代码来源:JSONImport.cs
示例13: OnInteractClick
public override void OnInteractClick(GameObject actor)
{
string resourceName = GetDialogResourceName ();
json = null;
if (!jsonOptions.ContainsKey (resourceName)) {
LoadDialog (resourceName);
}
if (!jsonOptions.ContainsKey (resourceName)) {
Debug.LogError ("No dialog found for resource named " + resourceName);
return;
}
json = jsonOptions [resourceName];
if (json == null) {
Debug.LogError ("No dialog found for resource named " + resourceName);
return;
}
states = new Dictionary<int, JSONNode> ();
JSONArray jsonStates = json ["states"].AsArray;
foreach (JSONNode stateChild in jsonStates.Children) {
states [stateChild ["state"].AsInt] = stateChild;
}
dialogState = GetInitialDialogState ();
InvokeJson (json ["onEnter"]);
DialogManager.Show ();
ShowDialogState ();
}
开发者ID:hannahjgb,项目名称:AdventureGameFiles,代码行数:30,代码来源:TalkableObjectWithDialog.cs
示例14: LoadActuator
public IEnumerator LoadActuator(JSONNode actuator)
{
//foreach Actuator
// Create Actuator
// yield return InitializeActuator
yield return null;
}
开发者ID:OpenAgInitiative,项目名称:gro-ui,代码行数:7,代码来源:FarmResource.cs
示例15: fromJson
void fromJson(JSONNode data)
{
Initialize (
int.Parse((string) data ["id"]),
(string) data ["answer"]
);
}
开发者ID:santiiiii,项目名称:AulaVirtual2,代码行数:7,代码来源:Answer.cs
示例16: AddCurveIngredients
public static void AddCurveIngredients(JSONNode ingredientDictionary , params string[] pathElements)
{
var name = ingredientDictionary["name"];
var path = MyUtility.GetUrlPath(pathElements.ToList(), name);
var numCurves = ingredientDictionary["nbCurve"].AsInt;
var pdbName = ingredientDictionary["source"]["pdb"].Value.Replace(".pdb", "");
SceneManager.Get.AddCurveIngredient(path, pdbName);
for (int i = 0; i < numCurves; i++)
{
//if (i < nCurve-10) continue;
var controlPoints = new List<Vector4>();
if (ingredientDictionary["curve" + i.ToString()].Count < 4) continue;
for (int k = 0; k < ingredientDictionary["curve" + i.ToString()].Count; k++)
{
var p = ingredientDictionary["curve" + i.ToString()][k];
controlPoints.Add(new Vector4(-p[0].AsFloat, p[1].AsFloat, p[2].AsFloat, 1));
}
SceneManager.Get.AddCurveIntance(path, controlPoints);
//break;
}
Debug.Log("*****");
Debug.Log("Added curve ingredient: " + path);
Debug.Log("Num curves: " + numCurves);
}
开发者ID:pmindek,项目名称:cellVIEWcut,代码行数:29,代码来源:CellPackLoader.cs
示例17: cargarJsonEscena
public void cargarJsonEscena()
{
//Compruebo en que escena estamos y cargo el json correspondiente.
switch (SceneManager.GetActiveScene().name)
{
case "Main":
sceneJson = JSONNode.Parse(jsons[0].text);
break;
case "Bar":
sceneJson = JSONNode.Parse(jsons[1].text);
break;
case "Estanco":
sceneJson = JSONNode.Parse(jsons[2].text);
break;
case "Oficina":
sceneJson = JSONNode.Parse(jsons[3].text);
break;
case "Iglesia":
sceneJson = JSONNode.Parse(jsons[4].text);
break;
//case "Main":
//break;
//case "Main":
//break;
}
}
开发者ID:CyborgGGJ,项目名称:Juego,代码行数:30,代码来源:GameManager.cs
示例18: TimedWeaponEvent
public TimedWeaponEvent(JSONNode N) : base(N)
{
interceptTargetID = N["interceptTargetID"].AsInt;
currentDistance = N["currentDistance"].AsFloat;
interceptTarget = GeoscapeVariables.TEM.EventList[interceptTargetID].icon;
}
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:7,代码来源:TimedWeaponEvent.cs
示例19: moveVertices
public void moveVertices(JSONNode positions)
{
Mesh mesh = GetComponent<MeshFilter> ().mesh;
Vector3[] vertices = mesh.vertices;
Vector3 invertY = new Vector3 (1, -1, 1);
// Set top left
JSONNode tl = positions["top_left"];
Vector3 tlverts = new Vector3 (tl["x"].AsFloat, tl["y"].AsFloat, 0);
vertices [3] = Vector3.Scale (tlverts, invertY);
// Set top right
JSONNode tr = positions["top_right"];
Vector3 trverts = new Vector3 (tr["x"].AsFloat, tr["y"].AsFloat, 0);
vertices [1] = Vector3.Scale (trverts, invertY);
// Set top left
JSONNode bl = positions["bottom_left"];
Vector3 blverts = new Vector3 (bl["x"].AsFloat, bl["y"].AsFloat, 0);
vertices [0] = Vector3.Scale (blverts, invertY);
// Set top left
JSONNode br = positions["bottom_right"];
Vector3 brverts = new Vector3 (br["x"].AsFloat, br["y"].AsFloat, 0);
vertices [2] = Vector3.Scale (brverts, invertY);
mesh.vertices = vertices;
mesh.RecalculateNormals ();
}
开发者ID:Distort-Mapping,项目名称:distortion,代码行数:30,代码来源:vertexPositions.cs
示例20: Update
void Update () {
if (canStart) {
if (Input.GetKeyDown(KeyCode.RightArrow)) {
Advance();
} else if (Input.GetKeyDown (KeyCode.LeftArrow)) {
Reverse();
}
if (_outro < 2f) {
_outro += Time.deltaTime;
if (_outro > 1.1f) {
Destroy(myoHub);
}
if (_outro > 1.5f) {
Application.LoadLevel("Scene2");
}
}
} else if (www != null && www.isDone) {
slides = JSONNode.Parse(www.text);
carousel.AddToCarousel(slides["slides"][slideMax]);
carousel.RotateCarousel();
slideMax++;
slideIndex++;
_locked = true;
canStart = true;
}
}
开发者ID:zwade,项目名称:OculusPresent,代码行数:26,代码来源:GenerateInternetSlide.cs
注:本文中的JSONNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论