Comments (6)
i have confirmed that it works in my environment as well. thank you for the quick response. this is a good project!
from fkyaml.
@adjbcbc
Thanks for sharing the issue and sorry for your inconvenience.
First of all, the fkyaml::node::deserialize()
function doesn't expect a file path as an input.
If you want to deserialize file contents, you must first open a file and pass the file handle, i.e., FILE*
or any object which can be interpreted as std::istream
, like the following:
#include <iostream>
#include <fstream> // ADDED
#include "fkYAML/node.hpp"
int main() {
std::ifstream ifs("./yamltest"); // ADDED
fkyaml::node root = fkyaml::node::deserialize(ifs); // CHANGED
for (const auto &ctx : root["contexts"]) {
std::cout << ctx["context"]["cluster"].get_value<std::string>(); // error
std::cout << ctx["context"]["bug"].get_value<std::string>(); // error
}
}
If a file path is given, fkYAML tries to parse the string ./yamltest
itself, which is why you encountered the reported error.
So, I tried the input with the above code and found a bug thanks to your report.
There seems to be a bug in handling indentation after a block sequence with the same indentation as its key node (line 9 in the YAML file).
Due to the bug, the node associated with the bug
key was mistakenly parsed as a child of the sequence node with extension
key.
Although I'm going to fix the bug hopefully this weekend, a quick workaround is to use the slightly modified version which works fine in my environment:
contexts:
- context:
cluster: abcdef
extension:
- extension:
last-update: blah
version: 0.1.0
name: blah
bug: default
ctx: ctx
from fkyaml.
@adjbcbc
The PR #348 has fixed the bug in parsing the YAML snippet you shared above.
Could you confirm if you can now get the correct parse result on the latest develop branch?
from fkyaml.
thinks for quick fix
i have confirmed that above example has been corrected properly.
but, i originally intended to try following file, but now encounted the following error.
terminate called after throwing an instance of 'fkyaml::v0_3_7::parse_error'
what(): parse_error: invalid flow mapping ending is found. (at line 26, column 14)
Aborted (core dumped)
apiVersion: v1
clusters:
- cluster:
certificate-authority: /home/x/.minikube/ca.crt
extensions:
- extension:
last-update: Mon, 27 May 2024 06:05:41 UTC
provider: minikube.sigs.k8s.io
version: v1.32.0
name: cluster_info
server: https://192.168.30.12:8441
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
last-update: Mon, 27 May 2024 06:05:41 UTC
provider: minikube.sigs.k8s.io
version: v1.32.0
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /home/x/.minikube/profiles/minikube/client.crt
client-key: /home/x/.minikube/profiles/minikube/client.key
how can i solve the above issue?
tools like kubectl had no problems reading that file
from fkyaml.
@adjbcbc
Thanks for confirming the fix and reporting the new issue.
The above error was caused because I forgot to implement for empty flow containers in the PR #350.
I can't think of a workaround for this issue, but it shouldn't require any major changes and will be fixed soon.
from fkyaml.
The error on empty flow containers has been fixed in the PR #351.
And I've checked that the parsing of the YAML file shared here succeeds with the modified parser, just locally though.
Can you please check if it can now be parsed with no issue in your environment too?
from fkyaml.
Related Issues (20)
- change integer scalar data type to int64_t only
- add more documents
- Misc Parse Errors HOT 7
- Parse errors on strings containing a single quote HOT 6
- Output stream conversion of nodes lacks quoting/escape of string values HOT 5
- The result of parsing UTF-16 encoded input lacks the last character HOT 1
- Cannot parse string which consists of numbers and multiple dots HOT 1
- Tutorial case HOT 9
- Comment crashes parser HOT 4
- Flow sequence and comma tokens in keys cause incorrect parse results HOT 4
- Incorrect parse result from plain scalars starting with special values HOT 1
- Crash due to comments right after sequence block keys
- Flow-style mapping values cause incorrect parse results HOT 3
- Mapping entries split across newlines cause incorrect parse results HOT 3
- Embedded flow indicators in plain unquoted scalar values cause incorrect parse results HOT 1
- Parse error on an alias node key
- too few template aruments HOT 5
- `get_value<int>()` and `get_value<float>()` reporting floating point underflow on value 0 HOT 8
- handle line advancement when parsing AnchorPrefix and TagPrefix HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fkyaml.