Re: yaml-cpp and YAML 1.2
Andrey Somov <[email protected]> Thu, 3 Mar 2016 22:44:28 +0100
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <CALbkv0cDcroQHv0CgOnzrsTfKXLsQr2fVWkJ-mi3LSThMkqWzQ@mail.gmail.com> |
Sorry, I will be more precise:
YAML:Node should be parsed differently for the same document:
{ a: true, b: 0x55 }
Failsafe Schema => { !!str a: !!str true, !!str b: !!str 0x55 }
JSON Schema => { !!str a: !!bool true, !!str b: !!str 0x55 }
Core Schema => { !!str a: !!bool true, !!str b: !!int 0x55 }
As you can see the tags should be different
Andrey
On Thu, Mar 3, 2016 at 10:35 PM, Jesse Beder <[email protected]> wrote:
> yaml-cpp doesn't even get so far as saying definitively what "a" and "b"
> are. It parses it as: "a" and "b" are nodes with certain values and tags.
> It doesn't assign types to them because that's the job of the application.
>
> What would it even mean to say that "b" is an integer in C++? The only way
> you can get an integer is to write
>
> int b = ...
>
> In other words, node["b"] cannot have type "int" or "string" or anything
> other than YAML::Node.
>
> On Thu, Mar 3, 2016 at 3:16 PM, Andrey Somov <[email protected]>
> wrote:
>
>> YAML:Node should be parsed differently for the same document:
>> { a: true, b: 0x55 }
>>
>> Failsafe Schema => a and b are strings
>>
>> JSON Schema => a is boolean, b is string
>>
>> Core Schema => a is boolean, b is integer
>>
>> SnakeYAML implements (almost) everything except schemas.
>> That is why SnakeYAML says it only supports YAML 1.1
>> If we do not have to respect schemas than many more parsers may become
>> YAML 1.2 compliant.
>> JS-YAML does support schemas in its API.
>>
>> Cheers,
>> Andrey
>>
>> On Thu, Mar 3, 2016 at 9:11 PM, Jesse Beder <[email protected]> wrote:
>>
>>> The examples are here:
>>>
>>> https://github.com/jbeder/yaml-cpp/blob/master/test/specexamples.h
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jbeder_yaml-2Dcpp_blob_master_test_specexamples.h&d=BQMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MTdCGdNVtXPX6PdqbNc8au-7Xx9X-p2GlN1e0U1iH9A&m=k0_S7vjNbEK3lfoTpRLHdSo404fP2giwHsXzgwMhUZo&s=iOczRD8wKG6Fb4kwEx5dU84FNAlhNBbAqX0MN-oMMDI&e=>
>>>
>>> and the tests are here:
>>>
>>>
>>> https://github.com/jbeder/yaml-cpp/blob/master/test/integration/handler_spec_test.cpp
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jbeder_yaml-2Dcpp_blob_master_test_integration_handler-5Fspec-5Ftest.cpp&d=BQMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MTdCGdNVtXPX6PdqbNc8au-7Xx9X-p2GlN1e0U1iH9A&m=k0_S7vjNbEK3lfoTpRLHdSo404fP2giwHsXzgwMhUZo&s=0lmPGSCYU7BQHiYVVDbjLmJyUsC1aWo8ZDvPV74gpsg&e=>
>>>
>>> https://github.com/jbeder/yaml-cpp/blob/master/test/integration/node_spec_test.cpp
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jbeder_yaml-2Dcpp_blob_master_test_integration_node-5Fspec-5Ftest.cpp&d=BQMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MTdCGdNVtXPX6PdqbNc8au-7Xx9X-p2GlN1e0U1iH9A&m=k0_S7vjNbEK3lfoTpRLHdSo404fP2giwHsXzgwMhUZo&s=GrPg-pjZuou6FFwNTNZ98Bi6ffqWgEOtSioD66xs89I&e=>
>>>
>>> As for parsing with schemas: what does it mean to parse with the JSON
>>> schema in C++? If I write
>>>
>>> X parsed = parseWithJsonSchema(...)
>>>
>>> what is the type of X? In yaml-cpp, the result of parsing is always
>>> YAML::Node, which then can be turned into any type you like statically.
>>>
>>> On Thu, Mar 3, 2016 at 9:48 AM, Andrey Somov <[email protected]>
>>> wrote:
>>>
>>>> Dear Jesse,
>>>> I looked in the source but I could not find the tests which take all
>>>> the examples form the specifications (as libyaml, PyYAML and SnakeYAML do).
>>>> Do you try to parse all the examples from the specification ?
>>>>
>>>> Cheers,
>>>> Andrey
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Mar 2, 2016 at 6:26 PM, Andrey Somov <[email protected]>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> >Happy to answer any questions.
>>>>>
>>>>> >Because C++ is statically typed and has no initial class, I always
>>>>> viewed schema >as an application task. yaml-cpp lets you deserialize to any
>>>>> application-specific >type, but you have to ask statically, so automatic
>>>>> resolution seems less useful.
>>>>>
>>>>> Dear Jesse,
>>>>> I did not quite catch you. Java is also statically typed, but it is
>>>>> unrelated to Recommended Schemas.
>>>>> The YAML 1.2 spec requires that the user may select (as an option) to
>>>>> parse the very same document with different schemas. JS-yaml does have
>>>>> support for that (partially).
>>>>>
>>>>> If I want to apply JSON schema and use yaml-cpp what should I do ?
>>>>>
>>>>>
>>>>> (other questions follow :-)
>>>>> Cheers,
>>>>> Andrey
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Site24x7 APM Insight: Get Deep Visibility into Application Performance
>>>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
>>>> Monitor end-to-end web transactions and take corrective actions now
>>>> Troubleshoot faster and improve end-user experience. Signup Now!
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
>>>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__pubads.g.doubleclick.net_gampad_clk-3Fid-3D272487151-26iu-3D_4140&d=BQMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MTdCGdNVtXPX6PdqbNc8au-7Xx9X-p2GlN1e0U1iH9A&m=k0_S7vjNbEK3lfoTpRLHdSo404fP2giwHsXzgwMhUZo&s=pKLzAZMELaY6L2GbZMeTfxOJLHOVQMrnTUVwYSEhI0Y&e=>
>>>> _______________________________________________
>>>> Yaml-core mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/yaml-core
>>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_yaml-2Dcore&d=BQMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=MTdCGdNVtXPX6PdqbNc8au-7Xx9X-p2GlN1e0U1iH9A&m=k0_S7vjNbEK3lfoTpRLHdSo404fP2giwHsXzgwMhUZo&s=ypqrRfifi5e368iHi12MRjxJw4HZ03n_o1BU4moQGc4&e=>
>>>>
>>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Site24x7 APM Insight: Get Deep Visibility into Application Performance
>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
>> Monitor end-to-end web transactions and take corrective actions now
>> Troubleshoot faster and improve end-user experience. Signup Now!
>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
>> _______________________________________________
>> Yaml-core mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/yaml-core
>>
>>
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core