• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFDUMP - hide option

Community Beginner ,
Jan 11, 2019 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.

Views

732

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 14, 2019 Jan 14, 2019

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

...

Votes

Translate

Translate
Community Expert ,
Jan 11, 2019 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

Dave Watts, Eidolon LLC

Votes

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
community guidelines
Community Expert ,
Jan 12, 2019 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>

Votes

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
community guidelines
Community Expert ,
Jan 12, 2019 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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Community Expert ,
Jan 13, 2019 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

Votes

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
community guidelines
Community Beginner ,
Jan 14, 2019 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>

Votes

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
community guidelines
Community Expert ,
Jan 14, 2019 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>

Votes

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
community guidelines
Community Beginner ,
Jan 14, 2019 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.

Votes

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
community guidelines
Community Expert ,
Jan 14, 2019 Jan 14, 2019

Copy link to clipboard

Copied

LATEST

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

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

Votes

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
community guidelines
Resources
Documentation