Is it possible to determine if a JSON object contains a specified "fieldname".
For example:
If I have a JSON Object such as:
{"event":
[
{"query":
{"id":
[
{"timestamp_usec":"1316596939223064"}
],
"query_text":"sometext"
}
},
{"query":
{"id":
[
{"timestamp_usec":"1316318681908642","type":"sometype","abc":"someabc"},
{"timestamp_usec":"1316318679366796"}
],
"query_text":"someothertext"
}
},
//...More...//
]
}
What can I use as my conditional within an if statement to determine if a particular "id object" contains an "abc"?
More Simply:
FOR ALL jsonpath id's
IF jsonpath.id **CONTAINS** "abc"
THEN do something
ELSE do something different
END LOOP
I'm looking for the jQuery function to achieve this (if there is one!).
My Code:
$.getJSON("test.json", function(data) {
var search = data.event
$.each(data.event, function(i, item) {
var searchMeta = data.event[i].query.id;
$.each(searchMeta[i], function(i, deeper){
if (searchMeta[i]. == "abc"){
//do something
} else {
//do something different
}
})
})
});
I know in the above example I could essentially achieve what I want by looping on the number of id objects, eg If num < 1. But I am not sure how uniform my data is throughout more than one .json file.
Try defining a function to call for each Object within data object
// property `name` to check
var name = "abc";
var check = function check(obj, name) {
// if `obj` is `Object` ,
// and `obj` has property `name` ,
// do stuff
if (/Object/.test(obj.constructor.toString())
&& obj.hasOwnProperty(name)) {
console.log(name + " found")
}
// else , do other stuff
else {
console.log(name + " not found")
}
};
$.each(data.event, function(key, value) {
check(value, name);
$.each(value.query, function(k, v) {
check(v, name);
// if `v` is an `Object` , call check for
// call `check` on each `v` `Object`
if (typeof v === "object") {
$.each(v, function(_k, _v) {
check(_v, name);
})
};
});
});
var data = {
"event": [{
"query": {
"id": [{
"timestamp_usec": "1316596939223064"
}],
"query_text": "sometext"
}
}, {
"query": {
"id": [{
"timestamp_usec": "1316318681908642",
"type": "sometype",
"abc": "someabc"
}, {
"timestamp_usec": "1316318679366796"
}],
"query_text": "someothertext"
}
}
//...More...//
]
};
var data = {
"event": [{
"query": {
"id": [{
"timestamp_usec": "1316596939223064"
}],
"query_text": "sometext"
}
}, {
"query": {
"id": [{
"timestamp_usec": "1316318681908642",
"type": "sometype",
"abc": "someabc"
}, {
"timestamp_usec": "1316318679366796"
}],
"query_text": "someothertext"
}
}
//...More...//
]
};
// property `name` to check
var name = "abc";
var check = function check(obj, name) {
// if `obj` is `Object` ,
// and `obj` has property `name` ,
// do stuff
if (/Object/.test(obj.constructor.toString())
&& obj.hasOwnProperty(name)) {
var res = {};
res[name] = obj[name];
$("body").append(JSON.stringify(res) + " found")
}
// else , do other stuff
else {
console.log(name + " not found")
}
};
$.each(data.event, function(key, value) {
check(value, name);
$.each(value.query, function(k, v) {
check(v, name);
// if `v` is an `Object` , call check for
// call `check` on each `v` `Object`
if (typeof v === "object") {
$.each(v, function(_k, _v) {
check(_v, name);
})
};
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
jsfiddle http://jsfiddle.net/yenp6t8v/
JSON.stringify(json) this will give you json as string then you can do REGEX to check if there is file in the json.
Related
I am trying to convert the keys in JSON to the capital case using Javascript. I am successful to some extent. However, it is not creating the arrays in the correct way. It is inserting numbers before every object inside an array.
Input:
{
"id": "123",
"retweetCheck": {
"result": "OK",
"checks": [
{
"cId": "123"
},
{
"cId": "456"
}
]
},
"tweetCheck": {
"result": "OK",
"cId": "345",
"check": "Fail"
}
}
Code to convert the keys to capital case:
var responseContent = context.getVariable("response.content") || "";
responseContent = JSON.parse(responseContent) || "";
transformedCapitalizedObj = keysToCapitalCase(responseContent);
var finalResponseObj = {
Data: transformedCapitalizedObj
};
context.setVariable("response.content", JSON.stringify(finalResponseObj));
The function
function objEntries(obj) {
const keys = Object.keys(obj);
const keyValuePairs = keys.map(key => {
const value = obj[key];
return [key, value];
});
return keyValuePairs;
}
function keysToCapitalCase(objToProcess) {
if (!objToProcess || typeof objToProcess !== "object") return null;
var finalObj = {};
objToProcess = objEntries(objToProcess);
objToProcess.forEach(function (entry) {
var key = entry[0];
var value = entry[1];
key = key.charAt(0).toUpperCase() + key.slice(1);
if (typeof value == "object" || (value instanceof Array)) {
value = keysToCapitalCase(value);
}
finalObj[key] = value;
});
return finalObj;
}
The output I am getting currently is:
{
"Data":{
"RetweetCheck":{
"Checks":{
"0":{
"CId":"123"
},
"1":{
"CId":"456"
}
},
"Result":"OK"
},
"Id":"123",
"TweetCheck":{
"CId":"345",
"Check":"Fail",
"Result":"OK"
}
}
}
But ideally, the output should look like this:
{
"Data": {
"Id": "123",
"RetweetCheck": {
"Result": "OK",
"Checks": [
{
"CId": "123"
},
{
"CId": "456"
}
]
},
"TweetCheck": {
"Result": "OK",
"CId": "345",
"Check": "Fail"
}
}
}
It is basically inserting a serial number before each object inside an array instead of []. How this can be rectified. Any help will really do wonders.
When you call your function keysToCapitalCase(), first check if you have an array (with ES6, you can do this using Array.isArray()), and if you do, you can map the objects / inner arrays within that array to the result of recursively calling your keysToCapitalize function. Otherwise, if you get a standard object that isn't an array, you can perform your standard object mapping:
const obj = { "id": "123", "retweetCheck": { "result": "OK", "checks": [{ "cId": "123" }, { "cId": "456" } ] }, "tweetCheck": { "result": "OK", "cId": "345", "check": "Fail" } };
function keysToCapitalCase(objToProcess) {
if (!objToProcess || typeof objToProcess !== "object") return null;
if(Array.isArray(objToProcess)) {
return objToProcess.map(obj => keysToCapitalCase(obj));
}
var finalObj = {};
objToProcess = Object.entries(objToProcess); // if you can support it, `Object.entries()` does what `objEntries` does
objToProcess.forEach(function(entry) {
var key = entry[0];
var value = entry[1];
key = key.charAt(0).toUpperCase() + key.slice(1);
if (typeof value == "object") {
value = keysToCapitalCase(value);
}
finalObj[key] = value;
});
return finalObj;
}
var finalResponseObj = {Data: keysToCapitalCase(obj)};
console.log(finalResponseObj);
I would probably write the above method in a similar way, but instead using some inbuilt functions to make it a little more concise, such as .map() and Object.fromEntries():
const obj = { "id": "123", "retweetCheck": { "result": "OK", "checks": [{ "cId": "123" }, { "cId": "456" } ] }, "tweetCheck": { "result": "OK", "cId": "345", "check": "Fail" } };
const cap = str => str.charAt(0).toUpperCase() + str.slice(1);
const keysToCapitalCase = (objToProcess) => {
if (Object(objToProcess) !== objToProcess) return null;
return Array.isArray(objToProcess)
? objToProcess.map(obj => keysToCapitalCase(obj))
: Object.fromEntries(Object.entries(objToProcess).map(([key, val]) => [
cap(key), Object(val) === val ? keysToCapitalCase(val) : val
]));
}
const finalResponseObj = {Data: keysToCapitalCase(obj)};
console.log(finalResponseObj);
As indicated by the {} brackets, instead of the wanted [] brackets you are creating an empty object and not an Array.
To create an Array just change your var finalObj = {}; to var finalObj = [];
with an Array finalObj[key] = value will no longer work, you will now have to use finalObj.push(value)
I have an object named obj that will be used as a basis to create a new array of objects in a certain format.
My base object:
var obj={
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
I created a function getObj() which accepts two arguments lang and the base object obj.
SAMPLE SCENARIOS
When I call:
getObj("en", obj);
I should get:
[{
"url": "/en/faq",
"links": [
{ lang: 'en', url: '/en/faq' },
{ lang: 'hi', url: '/hi/aksar-poochhe-jaane-vaale' }
]
},
{
"url": "/en/about",
"links": [
{ lang: 'en', url: '/en/about' },
{ lang: 'hi', url: '/hi/hamaare-baare' }
]
}]
When I call:
getObj("hi", obj);
I should get:
[{
"url": "/hi/aksar-poochhe-jaane-vaale",
"links": [
{ lang: 'en', url: '/en/faq' },
{ lang: 'hi', url: '/hi/aksar-poochhe-jaane-vaale' }
]
},
{
"url": "/hi/hamaare-baare",
"links": [
{ lang: 'en', url: '/en/about' },
{ lang: 'hi', url: '/hi/hamaare-baare' }
]
}]
Below is what I tried:
function getObj(lang, obj){
var newobj = {};
newobj['url'] = "/"+ lang +"/"+obj[lang].map(e=>e.faq);
var s ={lang: lang, url: newobj.url};
newobj['links']=[s];
return newobj;
}
Supports obj.en and obj.hi containing more than one object.
Disclaimer: This code does not output an array of objects as originally requested. Rather, it is a object keyed by "page". (This allows the code to be much more efficient.) If you require the exact output, look at the answer below.
var obj={
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
function getObj(origLang, obj) {
if (typeof obj !== 'object') { return false; }
let result = {};
Object.keys(obj).forEach((lang) => { // Loop languages
obj[lang].forEach((pages) => {
if (typeof pages !== 'object') { return false; }
Object.keys(pages).forEach((page) => { // Loop pages
const url = pages[page];
// Create array if doesn't exist
if (typeof result[page] == 'undefined') {
result[page] = {'url': '', 'links': []};
}
// If original lang, add the url
if (origLang == lang) { result[page]['url'] = `/${origLang}/${url}`; }
// Add the links
result[page]['links'].push({
'lang': lang,
'url': `/${origLang}/${url}`
});
});
});
});
return result;
}
// Output to console.
console.log('The "en" array');
console.log(getObj('en', obj));
console.log('The "hi" array');
console.log(getObj('hi', obj));
Older Version. More readable, but requires looping over the object twice.
var obj={
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
function getObj(lang, obj){
const target = obj[lang];
let results = [];
target.forEach((pages) => {
if (typeof pages !== 'object') { return false; }
Object.keys(pages).forEach((page) => {
const url = pages[page]; // Get the url
results.push({
'url': "/" + lang + "/" + url,
'links': getLinks(page, obj) // Form the links
});
});
});
return results;
}
function getLinks(page, obj) {
let links = [];
if (typeof obj !== 'object') { return false; }
Object.keys(obj).forEach((lang) => {
obj[lang].forEach((target) => {
links.push({
'lang': lang,
'url': "/" + lang + "/" + target[page]
});
});
});
return links;
}
// Output to console.
console.log('The "en" array');
console.log(getObj('en', obj));
console.log('The "hi" array');
console.log(getObj('hi', obj));
Old Javascript:
var obj={
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
function getObj(lang, obj){
var target = obj[lang],
results = [];
for (var i = 0; i < target.length; i++) {
var pages = target[i]; // Get the object {"faq": "faq", "about", "about"}
for (var page in pages) {
if (!pages.hasOwnProperty(page)) { continue; }
var url = pages[page]; // Get the url
results.push({
'url': "/" + lang + "/" + url,
'links': getLinks(page, obj) // Form the links
});
}
}
return results;
}
function getLinks(page, obj) {
var links = [];
for (var lang in obj) { // Loop through each language
if (!obj.hasOwnProperty(lang)) { continue; }
var targets = obj[lang];
for (var i=0; i < targets.length; i++) {
var target = targets[i];
links.push({
'lang': lang,
'url': "/" + lang + "/" + target[page]
});
}
}
return links;
}
// Output to console.
console.log('The "en" array');
console.log(getObj('en', obj));
console.log('The "hi" array');
console.log(getObj('hi', obj));
return can only return one value; the value you're expecting to be returned is a list and isn't contained by anything. This hasn't been a problem (yet) since there isn't any logic for how to handle subsequent values of lang (that have not been explicitly passed).
So you need to do two things:
Find lang keys that weren't used to build the first object and iterate over them to build subsequent items in the list
Pass a single object by containing the list in data structure. Since you're using JS, I'd recommend using an array.
You already have a working function for building the basic nested object, you just need a way to handle the other cases. The below should handle one or more languages; though if a valid lang isn't passed it returns prematurely:
var obj = {
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
function getOtherKeys(lang, obj) {
return Object.keys(obj).filter(key => key != lang)
}
// Repurposed your function
function getObj(lang, obj) {
var newobj = {};
newobj['url'] = "/" + lang + "/" + obj[lang].map(e => e.faq);
var s = {
lang: lang,
url: newobj.url
};
newobj['links'] = [s];
// my changes below to handle other links
var keys = getOtherKeys(lang, obj);
for (var key of keys) {
newobj['links'].push({
lang: key,
url: "/" + key + "/" + obj[key].map(e => e.faq)
})
}
return newobj;
}
// Wrapping your code in an array and handling zeroeth/other keys
function buildObj(lang, obj) {
var outerObj = [];
// remove the zeroth key
var otherKeys = getOtherKeys(lang, obj);
// Add the primary language
if (obj[lang]) {
outerObj.push(getObj(lang, obj));
} else {
return;
}
// Add all other languages
for (var key of otherKeys) {
outerObj.push(getObj(key, obj));
}
return outerObj;
}
var obj = {
"en": [{
"faq": "faq",
"about": "about"
}],
"hi": [{
"faq": "aksar-poochhe-jaane-vaale",
"about": "hamaare-baare"
}]
}
var en = buildObj("en", obj); // Call array wrapper
console.log(en);
var hi = buildObj("hi", obj);
console.log(hi);
I am getting JSON data like below example. Now I want get each value in separate variables like
var reviewDate ='2015-06-01T05:00:00Z'
var developers ='Ankur Shah,Srikanth Vadlakonda,Tony Liu, Qiuming Jie
var reviewers = 'mike,john'
var title='Test project'
var call =$.ajax({
url:url,
type:"GET",
dataType:"json",
headers:{
Accept:"application/json;odata=verbose"
}
});
call.done(function(data,textStatus,jqXHR){
alert("Success!! "+ jqXHR.responseText);
});
call.fail(function(jqXHR,textStatus,errorThrown){
alert("Error retriving Tasks!! "+ jqXHR.responseText);
});
I am getting results in call.done in . How to set those values?
You could do something along these lines:
http://jsfiddle.net/e0mfc1rd/2/
Javascript:
var data = {
results: {
Date_x0020_of_x0020_Review: '2015-06-01T05:00:00Z',
Name_x0020_of_x0020_Developers: {
results: [
{
__metadata: {},
Title: 'Ankur Shah'
},
{
__metadata: {},
Title: 'Tony Liu'
},
{
__metadata: {},
Title: 'Qiuming Jie'
}
]
},
Name_x0020_of_x0020_Reviewers: {
results: [
{
__metadata: {},
Title: 'Mike'
},
{
__metadata: {},
Title: 'John'
}
]
}
}
}
// map the key names.
// you could do something more clever here, like just extracting
// the segment after the last underscore using substring or a regex,
// but for this example we'll do a simple map.
var names = {
'Name_x0020_of_x0020_Reviewers': 'reviewers',
'Name_x0020_of_x0020_Developers': 'developers'
}
// a variable to hold the result.
var processed = {};
// iterate over each key in data.results
// (e.g. 'Name_x0020_of_x0020_Developers', 'Name_x0020_of_x0020_Reviewers', etc.)
Object.keys(data.results).forEach(function(k) {
// if the object indexed at that key has a 'results' property that is an array...
if (Array.isArray((data.results[k] || {}).results)) {
// pluck the Title attribute from each of those entries into a new array.
var values = data.results[k].results;
var titles = values.map(function(v) {
return v.Title;
});
// translate keys like 'Name_x0020_of_x0020_Reviewers'
// into something more palatable
var key = names[k] || k;
// join the titles into a string, separated by a comma
processed[key] = titles.join(',');
}
else if (k.indexOf('Date') === 0) { // key starts with 'Date'
processed[k] = new Date(data.results[k]);
}
});
After which the variable 'processed' would contain:
{
"Date_x0020_of_x0020_Review": "2015-06-01T05:00:00.000Z",
"developers": "Ankur Shah,Tony Liu,Qiuming Jie",
"reviewers": "Mike,John"
}
You could also use UnderscoreJS to get your data from your JSON.
You need to chain some pluck calls and you should get to your data.
Please find the demo below and here at jsFiddle.
To get the parsed object into your comma separated format just use for example: var developers = parsed.developers.join(',');
var resultJSON = {
d: {
__metadata: {},
"Name_x0020_of_x0020_Developers": {
"results": [{
"Title": "Ankur Shah"
}, {
"Title": "Srikanth"
}, {
"Title": "Tony Liu"
}]
},
"Name_x0020_of_x0020_Reviewers": {
"results": [{
"Title": "Name1"
}, {
"Title": "Name2"
}, {
"Title": "Name3"
}]
}
}
};
//console.log(resultJSON);
var names = {
developers: 'Name_x0020_of_x0020_Developers',
reviewers: 'Name_x0020_of_x0020_Reviewers'
};
var parsed = {};
_.each(names, function (name, key) {
parsed[key] = _.chain(resultJSON) // key is developers, reviewers
.pluck(name) // is the name in the JSON e.g. Name_..._Developers
.pluck('results')
.tap(function (data) { // tap is optional and can be removed
console.log('before flatten', data); // it shows the nesting [[]]
})
.flatten(true) // used to remove outer array
.tap(function (data) {
// we now have the result. Next, get the title
console.log('before getting the Title', data);
})
.pluck('Title')
.value();
});
console.log(parsed);
document.getElementById('output').innerHTML = JSON.stringify(parsed, null, 2);
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<pre id="output"></pre>
I would like to know what is the faster way to retrieve an object by its id, keeping in consideration that the structure where it is stored could be different.
Does any native function in JS for this operation?
Example 1
var source = {
"page": [{
"id": "1",
"site": "",
"items": [{
"id": "2"
}, {
"id": "3",
"anotherItem": [{
"id": "4"
}, {
"id": "5"
}]
}]
}, {
"id": "6"
}]
};
Example 2
Structure could be completely different, the script should be always able to get the object containing id.
{
"smtElse": {
"id": "1"
}
}
No, there is no native function.
The fastest way is the same as the only way which is to iterate over the object, probably recursively, looking for IDs and returning what you want.
I solved using the following script, as it seems no native functionality is available.
var data = {
item: [
{
itemNested: [
{
itemNested2: [{
id: "2"
}
]
}
]
}
]
};
function findById(obj, id) {
var result;
for (var p in obj) {
if (obj.id == id) {
return obj;
} else {
if (typeof obj[p] === 'object') {
result = findById(obj[p], id);
if (result) {
return result;
}
}
}
}
return result;
}
var result = findById(data, "2");
console.log(result);
you can try this
<script type="text/javascript">
var re = /"id":\s+"(.*?)"/;
var sourcestring = "source string to match with pattern";
var results = [];
var i = 0;
for (var matches = re.exec(sourcestring); matches != null; matches = re.exec(sourcestring)) {
results[i] = matches;
for (var j=0; j<matches.length; j++) {
alert("results["+i+"]["+j+"] = " + results[i][j]);
}
i++;
}
Here is what I want to do:
I have a tree (javascript object-literal structure) with multiple levels.
I have a value of a particular key of this object.
I want to search for this exact key-value pair in the structure and return the value of another key as an output.
For clarity following is my object literal:
{
"nodeId": 1081,
"appId": 150,
"displayText": "Welcome here",
"Nodes": [
{
"nodeId": 2000,
"appId": 150,
"displayText": "Buy",
"parentNodeId": 1081,
"Nodes": [
{
"nodeId": 2003,
"appId": 150,
"displayText": "tCars",
"parentNodeId": 2000,
"Nodes": [
{
"nodeId": 2006,
"appId": 150,
"displayText": "Diesel",
"parentNodeId": 2003,
"Nodes": [
{
"nodeId": 2008,
"appId": 150,
"displayText": "Price", //This is what I want as return value.
"parentNodeId": 2006,
"Nodes": [],
"nodeCode": "RN_1_1_2_1_3_2_4_1",
"parentCode": "RN_1_1_2_1_3_2",
"jumpToNode": "RN_1_1" //here is the value that I have with me.
}
],
"nodeCode": "RN_1_1_2_1_3_2",
"parentCode": "RN_1_1_2_1"
}
],
"concatWithHeader": false,
"nodeCode": "RN_1_1_2_1",
"parentCode": "RN_1_1"
}
],
"nodeCode": "RN_1_1",
"parentCode": "RN"
}
],
"nodeCode": "RN",
"parentCode": "ROOT_NODE"
}
2. Value that I have with me is "RN_1_1" against jumpToNode
3. I want to search in this object literal and get the value of the key displayText
I searched and tried few things for this but couldnt get the logic to iterate over the inner Nodes objects.
Method I wrote so far:
function getObjects(tree){
var searchkey="RN_1_1";
var displayText = "displayText";
var nodeCode = "nodeCode";
var returnText;
if (tree.hasOwnProperty(nodeCode)) {
var obj = tree[nodeCode];
if(obj == searchkey){
returnText = tree[displayText]; //gives me the return text
break;
}
else{
//here I should iterate over the inner `Nodes` and get the required value.
}
}
}
Please help.
Thanks.
I think you can do something like this which works recursively:
function findProperty(obj, prop, val, propToFetch) {
var answer;
if (obj.hasOwnProperty(prop) && obj[prop] === val) {
return obj[propToFetch];
}
for (var i = 0, len = obj.Nodes.length; i < len; i++) {
answer = findProperty(obj.Nodes[i], prop, val, propToFetch);
if (answer !== null) {return answer;}
}
return null;
}
var result = findProperty(data, "jumpToNode", "RN_1_1", "displayText");
Working demo here: http://jsfiddle.net/jfriend00/EjC5V/
Accordingly to your JSON object you can use this way:
var searchKey="RN_1_1",
displayText = "displayText",
nodeCode = "nodeCode",
returnText,
treeSearch = function (obj, searchKey) {
if (obj[nodeCode] === searchKey) {
returnText = obj[displayText];
} else {
if (obj['Nodes'][0]) {
treeSearch(obj['Nodes'][0], searchKey);
} else {
returnText = null
}
}
};
treeSearch(JSONdata, 'RN_1_1_2_1_3_2');
I have flattened the array using the nodeId to be easier to search through it.
After you flatten the array you can filter it as you wish(i suggest using underscorejs.org)
Here is the live example. The result is displayed in the console.
function flattenNodes (obj, newArr) {
if (obj && obj.Nodes) {
var nodes = obj.Nodes;
delete(obj.Nodes);
newArr[obj.nodeId] = obj;
return flattenNodes(nodes.pop(), newArr);
} else {
return newArr;
}
};
var flattenArr = flattenNodes(arr, new Array());
function findInJumpToNode(find) {
for(key in flattenArr) {
if (flattenArr[key] && flattenArr[key]['jumpToNode']) {
if (flattenArr[key]['jumpToNode'] == find) {
return flattenArr[key];
}
}
}
}
var found = findInJumpToNode('RN_1_1');
console.log(found);
You can use recursion to handle your case.
Check out this sample on jsFiddle.
var nodes= [getNodes()];
alert(getObjects(nodes));
function getObjects(tree){
var searchkey="RN_1_1_2_1_3_2_4_1";
var displayText = "displayText";
var nodeCode = "nodeCode";
var returnText;
if(tree.length > 0)
{
if(tree[0]["nodeCode"] === searchkey)
{
return tree[0][displayText];
}
if(typeof tree[0]["Nodes"] === "undefined")
{
return;
}
return getObjects(tree[0]["Nodes"]);
}
}