Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to access to the fullKeyList ? #8

Open
cedricvaneer opened this issue Oct 9, 2015 · 2 comments
Open

Is there a way to access to the fullKeyList ? #8

cedricvaneer opened this issue Oct 9, 2015 · 2 comments

Comments

@cedricvaneer
Copy link

Hello,

I need to load the keys dynamically so I would loop over a struct to get the keys to load.
But I could have the same key at multiple locations in my struct.
So I need to be able to detect if my current key is already defined in my serializer to avoid throwing an exception.

Here is part of my code :

serializer = new JSONSerializer()
    .asInteger( "clientId" )
    .asInteger( "dateEnd" )
    .asInteger( "dateStart" )
    .asString( "publishTarget" )
    .asString( "ip" )
    .asString( "language" )
    ...
;

for (key in struct){
    if (NOT structKeyExists( serializer.fullKeyList, key)){
        serializer = serializer.asAny(key);
    }
}

Is the fullKeyList available outside the component or do I have to add a getter ?

Cédric

@kevindb
Copy link

kevindb commented Oct 9, 2015

How can you have the same key in a struct more than once? Isn't a struct key unique by definition? Would you please show how you are defining your struct?

@cedricvaneer
Copy link
Author

The same key could be at different levels with structs containing structs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants