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

Update Spyc to 0.6.2: Fixes parsing error array entry on multiple lines #5

Open
blynx opened this issue Sep 21, 2017 · 6 comments
Open

Comments

@blynx
Copy link

blynx commented Sep 21, 2017

Hi,

I had a parsing issue where FieldtypeYaml threw the "Current level has both int and str keys, ..." exception. Spyc didn't correctly parse an array like this:

array:
    - "lorem"
    - "ipsum"
    - "dolor
    this is the other line which is mistaken for a new key but belongs to 'dolor'"

I replaced Spyc with the newest version and it solved that problem.
https://github.com/mustangostang/spyc/

Cheers,
Steffen

@owzim
Copy link
Owner

owzim commented Oct 5, 2017

Hi @blynx, thanks for the hint. I updated the dev branch. Will not merge into master just yet since there have been a couple of updates.

@blynx
Copy link
Author

blynx commented Oct 6, 2017

Nice!

Will the other updates actually handle the "Current level has both int and str keys" thing?
Ran into this a couple of times and I don't really get why this is needed. Probably something temporary?

Built my own module/wrapper for the PECL yaml extension now. Maybe you could consider making this optional? Or use Spyc as a fallback.

@owzim
Copy link
Owner

owzim commented Oct 7, 2017

Where is this wrapper? I could build in, that it uses that module, if it exists (is installed).

@owzim
Copy link
Owner

owzim commented Oct 7, 2017

Current level has both int and str keys, thus it's impossible to keep arr or convert to obj It's not possible with anything but parseAs='Associative Array'. How should an object/WireArray be constructed if it has both? object cannot have int keys, WireArray can, but str keys would only be properties of that WireArray and not be iterable, AND its child elements must be objects. What kind of scenario do you have where you would want both int and str keys?

@blynx
Copy link
Author

blynx commented Oct 9, 2017

Uhhmm, yep, I thought WireData/Array support them anyway so it doesn't really matter - but I don't remember now what setting I actually used! Thats true for objects ...

Oh, it's almost nothing, basically just replace the yaml parsing function somehow:

if (!extension_loaded('yaml')) {
    ...
} else {
    yaml_parse( $yaml_data );
}

This is the extension: https://pecl.php.net/package/yaml

@owzim
Copy link
Owner

owzim commented Oct 11, 2017

@blynx Updated the dev branch to include your code.

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