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

Removing elements from arrays #18

Open
ghost opened this issue Jul 10, 2013 · 2 comments
Open

Removing elements from arrays #18

ghost opened this issue Jul 10, 2013 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 10, 2013

If you load an array it gets treated as an object:

"expansion_prices": {
"0": {
"coins": 501,
"cash": 10
},
"1": {
"coins": 2002,
"cash": 15
},
"2": {
"coins": 3000,
"cash": 20
}, etc

instead of
"expansion_prices": [
[
"coins": 501,
"cash": 10
],
[
"coins": 2002,
"cash": 15
],
[
"coins": 3000,
"cash": 20
], etc.

which causes tons of issues when you are working with sensitive languages such as python for example. Any ideas how to fix this?

@ghost
Copy link
Author

ghost commented Jul 12, 2013

OK guys I found a solution. I saw the comment:
//TODO: Deal with array type
in onde.Onde.prototype._sanitizeFieldInfo
and I added a quick workaround. Not pretty at all but works. Inside the function, on the first line add

var stringified = JSON.stringify(valueData);

And where the comment is the following lines:

if ( stringified.charAt(0) == '[' )
{
fieldInfo.type = 'array';
}

And as far as I can see it works fine. I'll do some more testing and I'll let you know if there are any problems.

@ghost
Copy link
Author

ghost commented Jul 12, 2013

actually found an issue - cannot use charAt() on an object. So the if condition works as
if ( typeof stringified != 'undefined' && stringified.charAt(0) == '[' )
{
fieldInfo.type = 'array';
}

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

0 participants