Parsing CFDUMP struct and store values
Asked Answered
A

3

6

How do I parse this structure? I need to turn this into single variables. E.g. from the attributes struct:

name

type

value

I'm not familiar with structures, and I need to enter this type of data into a database.

I've played around with cfloop, but nothing.

cfdump

Alamode answered 29/8, 2010 at 19:50 Comment(1)
How do you want this data stored in a database? e.g. What is the purpose.Muldon
E
6

Assuming your variable name is "foo", you can access the name like this

foo.attributes.name

Structures are simply accessed via dot notation.

Erlineerlinna answered 29/8, 2010 at 21:47 Comment(0)
H
1

If you want to simply dump this structure, use a simple XML and store it in a CLOB or BLOB field. But if you want to perform operations such as search, frequent changes to the data, then its better you consider tree structures.

If you are using Oracle, take a look at CONNECT BY PRIOR, this makes you store values in the database directly as rows and later query them and load into a tree structure.

The gist here is you should both be able to store and retrieve data as if you are dealing with a simple TREE data structure.

Herewith answered 29/8, 2010 at 19:52 Comment(1)
well is there a way to get each field as a variable??? im using a function that parses a input as you see, now i just need the results so i can work with them. this function is located bennadel.com/blog/…Alamode
C
0

Along the same lines as what Ben said, I'm not sure why you'd want to pull this nice little struct apart. Use it in its current form by accessing the values inside it rather than disassembling it.

<cfloop collection="#foo.attributes#" item="myKey">
    <cfoutput>Value of #myKey# is #structFind(foo.attributes, myKey)#</cfoutput>
</cfloop>

Refer to the LiveDocs' structure looping page for more details.

Coligny answered 7/9, 2010 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.