本文整理汇总了C#中JsonObject.GetNamedArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetNamedArray方法的具体用法?C# JsonObject.GetNamedArray怎么用?C# JsonObject.GetNamedArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetNamedArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mapAssessmentJsonToAssessment
public static Assessment mapAssessmentJsonToAssessment(JsonObject assessmentJson)
{
Assessment assessment = new Assessment();
assessment.id = assessmentJson.GetNamedString("id");
assessment.title = assessmentJson.GetNamedString("assessmentTitle");
assessment.subject = assessmentJson.GetNamedString("academicSubject");
assessment.category = assessmentJson.GetNamedString("assessmentCategory");
var studentAssessmentArray = assessmentJson.GetNamedArray("studentAssessmentAssociation");
var studentAssessment = studentAssessmentArray[0].GetObject();
try
{
var startDate = studentAssessment.GetNamedString("administrationDate");
if (startDate != null) assessment.startDate = DateTime.Parse(startDate);
var endDate = studentAssessment.GetNamedString("administrationEndDate");
if (endDate != null) assessment.endDate = DateTime.Parse(endDate);
var scoreResults = studentAssessment.GetNamedArray("scoreResults");
var firstScore = scoreResults[0];
assessment.score = firstScore.GetObject().GetNamedString("result") + "/" + assessmentJson.GetNamedNumber("maxRawScore");
}
catch (Exception e)
{
}
assessment.description = "Bacon ipsum dolor sit amet meatloaf tail doner, sausage pig jowl flank chicken beef ribs drumstick leberkas ham rump ball tip prosciutto. Boudin pig prosciutto, leberkas ball tip meatloaf ham hock hamburger ribeye salami beef jerky. Pork belly pork chop tongue pancetta salami biltong capicola meatloaf prosciutto pastrami sirloin spare ribs. Tri-tip filet mignon tail beef ribs. Biltong flank ribeye short ribs, cow ground round brisket jerky pork.\n\n Turkey frankfurter meatball, shank fatback ball tip boudin shankle chuck. Shankle shoulder shank pig ham turkey brisket pork chop filet mignon. Strip steak sausage turkey, shank fatback filet mignon hamburger jowl. Pig bacon drumstick, swine chicken sausage prosciutto brisket strip steak doner ham pork loin bresaola shank. Doner beef capicola fatback pork belly, pork chop t-bone shank turducken andouille corned beef. Tail turducken sausage andouille chuck kielbasa pig bacon corned beef t-bone flank beef. Tenderloin chicken sirloin, tail swine turkey short ribs tongue meatball capicola ham spare ribs filet mignon kielbasa meatloaf.";
return assessment;
}
示例2: loadJsonInfo
async private void loadJsonInfo()
{
try
{
//--------- Having content from website--------------
HttpClient http = new HttpClient();
var response = await http.GetByteArrayAsync("http://emresevinc.github.io/exrepo.html");
String source = Encoding.GetEncoding("utf-8").GetString(response, 0, response.Length - 1);
source = WebUtility.HtmlDecode(source);
HtmlDocument resultat = new HtmlDocument();
resultat.LoadHtml(source);
List<HtmlNode> toftitle = resultat.DocumentNode.Descendants().Where
(x => (x.Name == "div" && x.Attributes["class"] != null &&
x.Attributes["class"].Value.Contains("container"))).ToList();
String text = toftitle[0].InnerText;
selectedMovie = new Movie();
//----------------------------------------------------
_jObject = JsonObject.Parse(text); // Burada json dosyası parse ediliyor.
jArr = _jObject.GetNamedArray("movies"); // Json verileri içindeki movies array'i
fillToMovieList();
}
catch (Exception)
{
new MessageDialog("Bir hata gerceklesti").ShowAsync();
}
}
示例3: Update
//note the async keyword - it's cause we're using an "await" method in our method body
public async void Update()
{
var client = new HttpClient();
//ooh fancy new await syntax!
//this actually executes in parallel and pauses the rest of the method's execution until it returns
//(in a non blocking way of course)
var result = await client.GetAsync(string.Format("http://search.twitter.com/search.json?q={0}&since_id={1}", SearchTerm, Since));
var root = new JsonObject(result.Content.ReadAsString());
var array = root.GetNamedArray("results");
for(int i = 0; i < array.Count; i++)
{
var element = array[i];
JsonObject obj = element.GetObject();
Tweet tweet = new Tweet
{
created_at = obj.GetNamedString("created_at"),
from_user = obj.GetNamedString("from_user"),
id_str = obj.GetNamedString("id_str"),
profile_image_url = obj.GetNamedString("profile_image_url"),
text = obj.GetNamedString("text")
};
if (!Tweets.Any(t => t.id_str == tweet.id_str))
{
Tweets.Insert(0, tweet);
}
}
}
示例4: read
public override Data read(JsonObject obj)
{
Article article = new Article();
try
{
article.Name = obj.GetNamedString("name");
article.Brand = obj.GetNamedObject("brand").GetNamedString("name");
JsonArray units = obj.GetNamedArray("units");
article.Price = units.GetObjectAt(0).GetNamedObject("price").GetNamedString("formatted");
JsonArray images = obj.GetNamedObject("media").GetNamedArray("images");
article.ThumbImage = images.GetObjectAt(0).GetNamedString("smallUrl");
}
catch(Exception e)
{
//TODO: log exception
System.Diagnostics.Debug.WriteLine(e.Message);
}
return article;
}
示例5: ShopDataItem
public ShopDataItem(JsonObject shopDataObject)
{
this.Id = shopDataObject.GetNamedString("id");
this.Name = shopDataObject.GetNamedString("name");
if (shopDataObject.Keys.Contains("businessLogo"))
{
var urlObj = shopDataObject.GetNamedObject("businessLogo");
if (urlObj.Keys.Contains("url"))
this.Logo = urlObj.GetNamedString("url");
}
var addressObj = shopDataObject.GetNamedObject("primaryAddress");
if (addressObj.Keys.Contains("addressLine"))
this.Address = addressObj.GetNamedString("addressLine");
if (addressObj.Keys.Contains("latitude"))
this.Latitiude = addressObj.GetNamedString("latitude");
if (addressObj.Keys.Contains("longitude"))
this.Longitude = addressObj.GetNamedString("longitude");
this.Suburb = addressObj.GetNamedString("suburb");
this.Categories = new List<ShopCategory>();
var categoriesObj = shopDataObject.GetNamedArray("categories");
var catCount = categoriesObj.Count;
for (uint i = 0; i < catCount; i++)
{
var cat = categoriesObj.GetObjectAt(i);
var catstr = cat.GetNamedString("id");
if (catstr.Equals("24414"))
this.Categories.Add(ShopCategory.Handbags);
else if (catstr.Equals("13927"))
this.Categories.Add(ShopCategory.Jewellery);
else if (catstr.Equals("27022"))
this.Categories.Add(ShopCategory.Shoes);
else if (catstr.Equals("27642"))
this.Categories.Add(ShopCategory.Sleepwear);
else if (catstr.Equals("16373"))
this.Categories.Add(ShopCategory.Watches);
else if (catstr.Equals("31917"))
this.Categories.Add(ShopCategory.Womenswear);
}
if (String.IsNullOrEmpty(this.FirstCategory))
this.FirstCategory = this.Categories.First().ToString();
}
示例6: GameSearchResults
//----------------------------------------------------------------------
public GameSearchResults( JsonObject aJsonObject )
{
Total = Convert.ToInt32( aJsonObject.GetNamedNumber( scTotalString ) );
Links = new Links( aJsonObject.GetNamedObject( scLinksString ) );
var theGameList = new List<Game>();
var theTop = aJsonObject.GetNamedArray( scTopString );
foreach( var theGame in theTop )
{
theGameList.Add( new Game( theGame.GetObject() ) );
}
GamesList = theGameList;
}
示例7: ParseExtentedBookItem
private static ExtendedBookItem ParseExtentedBookItem(JsonObject j)
{
var book = new ExtendedBookItem();
book.SeriesId = ((int)j.GetNamedNumber("_id")).ToString();
book.Title = j.GetNamedString("name");
book.CoverImageUri = j.GetNamedString("cover");
book.Publisher = j.GetNamedString("publisher");
book.Catalogs = j.GetNamedArray("cat").Select(value => ((BookCatalog)value.GetNumber())).ToList();
book.Volumes = j.GetNamedArray("vols").Select((v) =>
{
var val = v.GetObject();
string key = val.GetNamedString("_id");
var value = val.GetNamedArray("chaps").Select(c => c.GetObject().GetNamedString("_id")).ToList();
var pair = new KeyValuePair<string, List<string>>(key, value);
return pair;
}).ToList();
return book;
}
示例8: ResolvedActionFromJsonObject
/// <summary>
/// Parses and constructs a ResolvedAction instance from the given JSON data.
/// </summary>
/// <param name="contentJson"></param>
/// <returns>A newly created ResolvedAction instance.</returns>
public static ResolvedAction ResolvedActionFromJsonObject(JsonObject contentJson)
{
var resolvedAction = new ResolvedAction();
var obj = contentJson.GetObject();
var type = (int)obj.GetNamedValue(KeyType).GetNumber();
var actionUUID = obj.GetNamedString(KeyActionUuid);
var trigger = (int)obj.GetNamedNumber(KeyTrigger);
var delaySeconds = JsonHelper.Optional(obj, KeyDelayTime, 0);
var jsonContent = obj.GetNamedObject(KeyContent);
var sendOnlyOnce = JsonHelper.OptionalBoolean(obj, KeySendOnlyOnce, false);
var beacons = contentJson.GetNamedArray(KeyBeacons);
var supressionTime = JsonHelper.Optional(obj, KeysupressionTime, -1);
var reportImmediately = JsonHelper.OptionalBoolean(obj, KeyReportImmediately, false);
// TimeFrames
if (obj.ContainsKey(KeyTimeframes))
{
if (obj.GetNamedValue(KeyTimeframes).ValueType == JsonValueType.Array)
{
var keyframes = obj.GetNamedArray(KeyTimeframes);
foreach (var frame in keyframes)
{
if (frame.ValueType == JsonValueType.Object)
{
string start = JsonHelper.OptionalString(frame.GetObject(), KeyStart);
string end = JsonHelper.OptionalString(frame.GetObject(), KeyEnd);
DateTimeOffset? startOffset = null;
DateTimeOffset? endOffset = null;
var newFrame = new Timeframe();
if (start.Length > 5)
{
startOffset = DateTimeOffset.Parse(start);
}
if (end.Length > 5)
{
endOffset = DateTimeOffset.Parse(end);
}
resolvedAction.Timeframes.Add(new Timeframe() { Start = startOffset, End = endOffset });
}
}
}
}
foreach (JsonValue resp in beacons)
{
if (resp.ValueType == JsonValueType.String)
{
resolvedAction.BeaconPids.Add(resp.GetString(), 1);
}
}
BeaconAction action = ActionFactory.CreateBeaconAction(type, jsonContent, actionUUID);
resolvedAction.BeaconAction = action;
resolvedAction.EventTypeDetectedByDevice = (BeaconEventType)trigger;
resolvedAction.Delay = delaySeconds;
resolvedAction.SendOnlyOnce = sendOnlyOnce;
resolvedAction.SupressionTime = supressionTime;
resolvedAction.ReportImmediately = reportImmediately;
return resolvedAction;
}
示例9: ResolveAccountBeaconId1s
private void ResolveAccountBeaconId1s(JsonObject content)
{
AccountBeaconId1s.Clear();
JsonArray responses = content.GetNamedArray(KeyAccountBeaconId1s);
string beaconId1 = string.Empty;
foreach (JsonValue resp in responses)
{
if (resp.ValueType == JsonValueType.String)
{
beaconId1 = resp.GetString();
AccountBeaconId1s.Add(beaconId1);
}
}
}
示例10: GetHighestEntity
private string GetHighestEntity(JsonObject json)
{
var entities = json.GetNamedArray("entities");
var highestEntity = "";
double highestEntityScore = 0;
foreach (var jsonValue in entities)
{
var entity = jsonValue.GetObject();
var score = entity.GetNamedNumber("score");
if (!(score > highestEntityScore))
continue;
highestEntityScore = score;
highestEntity = entity.GetNamedString("entity");
}
return highestEntity;
}
示例11: GetHighestInent
private string GetHighestInent(JsonObject json)
{
var intents = json.GetNamedArray("intents");
var highestIntent = "";
double highestIntentScore = 0;
foreach (var jsonValue in intents)
{
var intent = jsonValue.GetObject();
var score = intent.GetNamedNumber("score");
if (!(score > highestIntentScore))
continue;
highestIntentScore = score;
highestIntent = intent.GetNamedString("intent");
}
return highestIntent;
}
示例12: LoadState
/// <summary>
/// Populates the page with content passed during navigation. Any saved state is also
/// provided when recreating a page from a prior session.
/// </summary>
/// <param name="navigationParameter">The parameter value passed to
/// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
/// </param>
/// <param name="pageState">A dictionary of state preserved by this page during an earlier
/// session. This will be null the first time a page is visited.</param>
protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
// Allow saved page state to override the initial item to display
if (pageState != null && pageState.ContainsKey("SelectedItem"))
{
navigationParameter = pageState["SelectedItem"];
}
String YWSID = "Bi9Fsbfon92vmD4DkkO4Fg";
String url;
if (navigationParameter != null && navigationParameter != "")
{
model = (Model)navigationParameter;
}
if (model != null)
{
url = "http://api.yelp.com/business_review_search?term=food&location=" + model.Location + "&ywsid=" + YWSID;
}
else
{
Geolocator locator = new Geolocator();
Geoposition geoPos = await locator.GetGeopositionAsync();
Geocoordinate geoCoord = geoPos.Coordinate;
url = "http://api.yelp.com/business_review_search?term=food&lat=" + geoCoord.Latitude + "&long=" + geoCoord.Longitude + "&ywsid=" + YWSID;
}
var httpClient = new HttpClient();
String content = await httpClient.GetStringAsync(url);
response = JsonObject.Parse(content);
if (response.GetNamedArray("businesses").Count == 0)
{
if (model != null)
{
model.error = true;
GoBack(this, null);
}
else
{
this.Frame.Navigate(typeof(LocationEntryPage));
}
}
else
{
StopLoading();
PopulateNewRestaurant();
}
}
示例13: read
public override Data read(JsonObject obj)
{
FacetGroup facetGroup = new FacetGroup();
Facet facet = new Facet();
try
{
facetGroup.GroupName = obj.GetNamedString("filter");
JsonArray root = obj.GetNamedArray(arrayName);
facet.readList<Facet>(root, facetGroup.Items);
}
catch (Exception e)
{
//TODO: log exception
System.Diagnostics.Debug.WriteLine(e.Message);
}
return facetGroup;
}
示例14: AssignMarks
private static void AssignMarks(LtpCourse course, JsonObject marksObject)
{
if (marksObject.GetNamedBoolean("supported") == false)
{
course.InternalMarksScored = 0;
course.TotalMarksTested = 0;
return;
}
double marksScored = 0;
JsonArray marksArray = marksObject.GetNamedArray("assessments");
foreach (JsonValue marksValue in marksArray)
{
JsonObject markStubObject = marksValue.GetObject();
string title = markStubObject.GetNamedString("title").ToUpper();
int maxMarks = (int)markStubObject.GetNamedNumber("max_marks");
int weightage = (int)markStubObject.GetNamedNumber("weightage");
MarkInfo markInfo;
if (markStubObject.GetNamedValue("scored_marks").ValueType == JsonValueType.Null)
markInfo = new MarkInfo(course, title, maxMarks, weightage, null, null, "");
else
{
markInfo = new MarkInfo(course, title, maxMarks, weightage,
null, // currently, 'conducted date' is being skipped.
markStubObject.GetNamedNumber("scored_marks"),
markStubObject.GetNamedString("status").ToUpper());
marksScored += (double)markInfo.WeightedMarks;
course.TotalMarksTested += markInfo.Weightage;
}
course.AddMarkInfo(markInfo);
}
course.InternalMarksScored = Math.Round(marksScored, 2);
}
示例15: AssignBaseTypeDetails
// Depth 1 Assignment (Ltp and NonLtp)
private static void AssignBaseTypeDetails(LtpCourse ltpCourse, JsonObject courseObject)
{
ltpCourse.Slot = courseObject.GetNamedString("slot");
ltpCourse.Venue = courseObject.GetNamedString("venue");
AssignTimings(ltpCourse, courseObject.GetNamedArray("timings"));
AssignAttendance(ltpCourse, courseObject.GetNamedObject("attendance"));
JsonObject marksObject = courseObject.GetNamedObject("marks");
AssignMarks(ltpCourse, marksObject);
}