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

error on parsing block string #30

Closed
nasa9084 opened this issue Nov 7, 2019 · 2 comments · Fixed by #32
Closed

error on parsing block string #30

nasa9084 opened this issue Nov 7, 2019 · 2 comments · Fixed by #32

Comments

@nasa9084
Copy link
Contributor

nasa9084 commented Nov 7, 2019

environment: go 1.13.4

(日本語でいいでしょうか・・・)

次の様な複数行文字列をパースしている際に文字列中でエラーが発生しました。

foo:
  value: |
     {
      "versions": [
            {
              "status": "CURRENT",
              "updated": "2011-01-21T11:33:21Z",
              "id": "v2.0",
              "links": [
                  {
                      "href": "http://127.0.0.1:8774/v2/",
                      "rel": "self"
                  }
              ]
          },
          {
              "status": "EXPERIMENTAL",
              "updated": "2013-07-23T11:33:21Z",
              "id": "v3.0",
              "links": [
                  {
                      "href": "http://127.0.0.1:8774/v3/",
                      "rel": "self"
                  }
              ]
          }
      ]
     }

.foo.value以下はすべて文字列となる、という想定で、gopkg.in/yaml.v2では問題なく動作していたものです。
エラーメッセージは次の様なものです。

--- FAIL: TestAPIWithExample (0.00s)
    unmarshalyaml_test.go:25: [66:51] failed to parse flow mapping value node
              62 | }
              63 |                             ]
              64 |                         },
              65 |                         {
            > 66 |                             "status": "EXPERIMENTAL",
              67 |                             "updated": "2013-07-23T11:33:21Z",
                                                                    ^
              68 |                             "id": "v3.0",
              69 |                             "links": [
              70 |                                 {
FAIL

当該部分は文字列なので、(インデントが足りないとかを除いて)途中でエラーが発生するというのは挙動として正しくないように思えます。

再現用Playground: https://play.golang.org/p/yLh0AZ5lQ62

@goccy
Copy link
Owner

goccy commented Nov 7, 2019

ご報告ありがとうございます!
こちら原因がわかりましたので、取り急ぎ修正いたします!

@goccy
Copy link
Owner

goccy commented Nov 7, 2019

#32 で修正しました!

@goccy goccy closed this as completed in #32 Nov 8, 2019
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

Successfully merging a pull request may close this issue.

2 participants