Now to get node values from json fetch

Team i need your help to get individual node values from a json fetch. I need this in order to run functions depeding on the value of each node.

What have you tried?

Did you look at the News feed example? https://www.fusetools.com/examples/news-feed

Yes i tried and succeded pulling the data and displaying the data using each. But what i need is to get an specific node value.

Example my json file is

[{“Name”:“Marco”,“Seconds”:123,“Other”:4},{“Name”:“David”,“Seconds”:45,“Other”:3}] And i want to assign the value of of seconds node 1 to a variable then using a function convert seconds to h:mm:ss. And i also want to pass the variable to a conditional expression. (if Other is == then)

My issue is geting node values then assign then to a observable variable to do magic

This is normal JavaScript programming. var seconds = json[0].Seconds;

Thanks i was writing the expression inverse. LOL

:S i just got home and im still having and error.undefined cannot be converted to an object. I paste the code in a min. Thanks

Help please im a noob, ErrorMessage: undefined cannot be converted to an object

    <JavaScript>        var Observable = require("FuseJS/Observable");

        var callstats = Observable();
        var test1 = Observable();


        fetch('http://localhost/marmarti/json/calls.json&#39;)
        .then(function(result) { 
            result.json().then(function(data) {
                    debug_log("Success");
                    for (var i = 0; i<data.length; i++) {
                        var item = data[i];
                        callstats.add(item);

                    }
                });
             });

        test1 = callstats[1].EnterpriseName;

        module.exports = {
            testos: callstats,
            test1: test1
        };

    </JavaScript>

Found the solution using case function :slight_smile:

Good. If you need more help, please post the JSON as well. :slight_smile:

Bjørn-Olav Strand, I still need help (T_T) . I didnt acheive the results i was looking for, using each match and case. I would like to get the node values from javascript like and assign that to an Observable variable:

eng.value = callstats[0].RouterCallsQNow + callstats[8].RouterCallsQNow;

Below my Json and JavaScript files thanks in advance.

Json File

[{"EnterpriseName":"ENGLISH_OPC1","RouterCallsQNow":20,"DATES":0},{"EnterpriseName":"FRENCH_FRA","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"FRENCH_CAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"PORTUGUES_POR","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"PORTUGUES_BRA","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"ITALIAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"GERMAN","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"SPANISH","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"ENGLISH_OPC2","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"OPT7","RouterCallsQNow":0,"DATES":0},{"EnterpriseName":"OPC3","RouterCallsQNow":0,"DATES":0}]

And JavaScript

<App Theme="Basic" ClearColor="#eeeeeeff">
        <JavaScript>            var Observable = require("FuseJS/Observable");

            var callstats = Observable();

var myVar = setInterval(loadall, 1000);

function loadall() {
load_calls_queue();
}


function load_calls_queue (){
    callstats.clear();
    var myRequest = new Request('http://localhost/marmarti/json/calls.json&#39;);

            fetch(myRequest)
            .then(function(response) { 
                return response.json().then(function(data) {
                        debug_log("Success");
                        for (var i = 0; i<data.length; i++) {
                            var item = data[i];
                            callstats.add(item);
                        }
                    });
                });
            }


            module.exports = {
                testos: callstats
            };
        </JavaScript>

To access Observables use getAt

eng.value = callstats.getAt(0).RouterCallsQNow + callstats.getAt(8).RouterCallsQNow;

Wow thanks a lot i feel like anakin skywalker. its workig… Its working!!!