Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:03:24+00:00 2026-05-26T05:03:24+00:00

Here is a short sample of the object I am working with. { myservices:

  • 0

Here is a short sample of the object I am working with.

{
    "myservices": [
        {
            "name": "oozie",
            "hostidn": "1",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        },
        {
            "name": "oozie",
            "hostidn": "2",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        },
        {
            "name": "oozie",
            "hostidn": "3",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        },
        {
            "name": "oozie",
            "hostidn": "4",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        },
        {
            "name": "oozie",
            "hostidn": "5",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        },
        {
            "name": "single-namenode",
            "hostidn": "2",
            "details": "failed process health monitor....",
            "currstatus": "Warning",
            "currstatusclass": "warning"
        }
    ]
}

I ultimately want to find what the highest “hostidn” is before running through all these and displaying them. hostidn is a Nth number it can be the only number or it can be hundreds deep with several duplicates in between. My Goal is to find that highest one and do a for or while loop on it based on that to group them together in a visual display. Example notice I have one hostidn below with the number 2 while all the rest have there own. I would want to group the two with 2 together in a box for display but there is 5 different hostidn in this scenario. I dunno maybe I am thinking it over wrong I’ll take suggestions however.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:03:25+00:00Added an answer on May 26, 2026 at 5:03 am

    basic algo you can follow

    declare and set a variable to zero like

    $currentHighest=0;

    then iterate over the json array and on each iteration campare the value of hostidn with the $currentHighest if the value is higher than the value already existing in the $currentHighest set that value to $currentHighest

    $currentHighest=0;
     $(data.myservices).each(function(index, element){
       if(data.myservices[index].hostidn>$currentHighest)
         $currentHighest=data.myservices[index].hostidn;
      });
    //loop ends and `$currentHighest` will have the highest value
    

    at the end of the iteration you will get the highest value in the $currentHighest

    Tried and tested

    $(function(){
     $.post("highest.json",function(data){
     $currentHighest=0;
      $(data.myservices).each(function(index, element){
       if(data.myservices[index].hostidn>$currentHighest)
         $currentHighest=data.myservices[index].hostidn;
      });
    alert($currentHighest);
    },'json');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the sample program I am working on to read a file with
Here's a short sample of my code: def update_records! # Teams. home_team_record = PoolRecord.for_recordable_and_user(event_home_team,
First question here: it is a very short yet fundamental thing in Java that
Here's the following algorithm: int encryption(int a, int b) { short int c, c2;
So here's a snippet of my code: struct dv_nexthop_cost_pair { unsigned short nexthop; unsigned
Short question - how do you define your view models? Here are some of
Here's a sort of odd question. I'm in the process of writing a book
Here is a sample code that I have: void test() { Object1 *obj =
Short version: I'm extending a jQuery object function that is intended to take 0-3
here's a simple and short code I've been trying to run: #include <stdio.h> int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.