Highlighted

CFDUMP - hide option

New Here ,
Jan 11, 2019

Copy link to clipboard

Copied

I am trying to figure out how to reference a 2nd level key within a structure for the purpose of hiding it within a CFDUMP.  If I just CFOUTPUT it, I can use one of these references and the value outputs perfectly:

- #test.level1.level2#

- #test["level1"]["level2"]#

But if I don't want CFDUMP to output test.level1.level2, I can't get it to work (e.g. hide='what?').  I've tried these permutations, with no success.

- level1.level2

- test.level1.level2

- level1["level2"]

- test["level1"]["level2"]

Any ideas?  Thanks.

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

fgwenger  wrote

// Dump while hiding the key "level2"

writedump(var=test, hide="[what do I put here to hide 'level2'?]");

My guess is that you cannot use the hide attribute in this way. That is because the value of the hide attribute must be a key or list of keys of the structure to be dumped.

In your example, test has one key, level1. If you hide it, test["level1"]["anotherLevel2"] will be hidden.

But you could solve the problem differently. Use an approach similar to the one I gave at the beginning:

<cfscript>

test["level1"]["level2"]=1;

test["level1"]["anotherLevel2"]=2;

// store copy of the original struct, in case you need it later

testCopy=duplicate(test);

// delete the test.level1.level2

structDelete(test.level1, "level2");

writedump(test);

</cfscript>

Views

272

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CFDUMP - hide option

New Here ,
Jan 11, 2019

Copy link to clipboard

Copied

I am trying to figure out how to reference a 2nd level key within a structure for the purpose of hiding it within a CFDUMP.  If I just CFOUTPUT it, I can use one of these references and the value outputs perfectly:

- #test.level1.level2#

- #test["level1"]["level2"]#

But if I don't want CFDUMP to output test.level1.level2, I can't get it to work (e.g. hide='what?').  I've tried these permutations, with no success.

- level1.level2

- test.level1.level2

- level1["level2"]

- test["level1"]["level2"]

Any ideas?  Thanks.

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

fgwenger  wrote

// Dump while hiding the key "level2"

writedump(var=test, hide="[what do I put here to hide 'level2'?]");

My guess is that you cannot use the hide attribute in this way. That is because the value of the hide attribute must be a key or list of keys of the structure to be dumped.

In your example, test has one key, level1. If you hide it, test["level1"]["anotherLevel2"] will be hidden.

But you could solve the problem differently. Use an approach similar to the one I gave at the beginning:

<cfscript>

test["level1"]["level2"]=1;

test["level1"]["anotherLevel2"]=2;

// store copy of the original struct, in case you need it later

testCopy=duplicate(test);

// delete the test.level1.level2

structDelete(test.level1, "level2");

writedump(test);

</cfscript>

Views

273

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 11, 2019 0
Adobe Community Professional ,
Jan 11, 2019

Copy link to clipboard

Copied

This is kind of difficult, because CFDUMP is designed to take a "top-level" variable so to speak and dump it in its entirety, so you can see all the delicious goodness inside. So, I think what you'd have to do is pass it by value to another variable, and dump that instead. If it's in an array, you should be fine doing something like this:

<cfset dumpMe = test.level1.level2>

then using CFDUMP with that.

Dave Watts, Eidolon LLC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 11, 2019 0
Adobe Community Professional ,
Jan 12, 2019

Copy link to clipboard

Copied

You could just clear the second level before dumping. For example,

<cfscript>

x["y"]["r"]=1;

x["y"]["s"]=2;

// store copy of original struct, in case you need it later

xCopy=duplicate(x);

// clear the second level

structclear(x["y"]);

 

writedump(x);

</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2019 0
Adobe Community Professional ,
Jan 12, 2019

Copy link to clipboard

Copied

You refer to hiding a key but you don't indicate having tried the hide attribute of cfdump (added in cf8) . Can you confirm if that did not work for you?

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2019 0
Adobe Community Professional ,
Jan 13, 2019

Copy link to clipboard

Copied

Good question from Charlie. I had assumed all keys in level 2 are to be hidden.

fgwenger​ , rereading your post once again, following Charlie's question, it is now clear what you ask. You wish to know how the hide attribute works. The answer is:

<cfscript>

test["level1"]["level2"]=1;

test["level1"]["anotherLevel2"]=2;

// Dump while hiding the key "level2"

writedump(var=test["level1"], hide="level2");

</cfscript>

Remember, the key is hidden when you dump test["level1"], but is visible when you dump test

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 13, 2019 0
New Here ,
Jan 14, 2019

Copy link to clipboard

Copied

I want to dump "test", but hide "level2" (and still show "anotherlevel2"). 

<cfscript>

test["level1"]["level2"]=1;

test["level1"]["anotherLevel2"]=2;

// Dump while hiding the key "level2"

writedump(var=test, hide="[what do I put here to hide 'level2'?]");

</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2019 0
Adobe Community Professional ,
Jan 14, 2019

Copy link to clipboard

Copied

fgwenger  wrote

// Dump while hiding the key "level2"

writedump(var=test, hide="[what do I put here to hide 'level2'?]");

My guess is that you cannot use the hide attribute in this way. That is because the value of the hide attribute must be a key or list of keys of the structure to be dumped.

In your example, test has one key, level1. If you hide it, test["level1"]["anotherLevel2"] will be hidden.

But you could solve the problem differently. Use an approach similar to the one I gave at the beginning:

<cfscript>

test["level1"]["level2"]=1;

test["level1"]["anotherLevel2"]=2;

// store copy of the original struct, in case you need it later

testCopy=duplicate(test);

// delete the test.level1.level2

structDelete(test.level1, "level2");

writedump(test);

</cfscript>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2019 0
New Here ,
Jan 14, 2019

Copy link to clipboard

Copied

I agree, I don't think it is possible.  I ended up "hiding" a whole level, and then separately dumping a couple of the other pieces of that hidden level that I needed.  I was hoping I could do it in one step.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2019 0
BKBK LATEST
Adobe Community Professional ,
Jan 14, 2019

Copy link to clipboard

Copied

Please mark the correct answer. It may be your own post.

This will help someone else looking for an answer to a similar problem.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 14, 2019 0