本文整理汇总了C#中JSONNode类的典型用法代码示例。如果您正苦于以下问题:C# JSONNode类的具体用法?C# JSONNode怎么用?C# JSONNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONNode类属于命名空间,在下文中一共展示了JSONNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
示例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"]);
}
示例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();
}
示例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;
}
}
示例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));
}
}
}
示例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);
}
}
示例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);
}
示例9: WriteToStream
public void WriteToStream(JSONNode pNode, Stream s)
{
using (textWriter = new StreamWriter(s))
{
WriteToStream(pNode, textWriter);
}
}
示例10: Level
public Level(JSONNode docLevel)
{
initRooms(docLevel["rooms"]);
initPositions(docLevel["positions"]);
initLinks(docLevel["links"]);
initPlayer(docLevel["player"]);
}
示例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);
}
示例12: ApplyData
void ApplyData(JSONNode masterJSON)
{
Debug.Log("Appling Data from JSON");
SetTitle(masterJSON[0]);
SetMaxObjects(masterJSON[1]);
SetButtonData(masterJSON[2]);
}
示例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 ();
}
示例14: LoadActuator
public IEnumerator LoadActuator(JSONNode actuator)
{
//foreach Actuator
// Create Actuator
// yield return InitializeActuator
yield return null;
}
示例15: fromJson
void fromJson(JSONNode data)
{
Initialize (
int.Parse((string) data ["id"]),
(string) data ["answer"]
);
}