FAQ
JSON and YAML are just representations of basic data structures (in Python
they'd be called dictionaries, lists and strings).

Perhaps the easiest way would be to write your data in YAML, load it in
python, then write it out in JSON. In most instances the native Python
representation is close enough to JSON that you might not need to do the
second conversion:

$ python
import yaml, json
data = yaml.load(open('myfile.yaml', 'r').read(-1))
print(data)
json.dumps(data)
You'll find that a lot of idiomatic salt states are a little more awkward
in JSON vs YAML (eg, state options are lists of single-key dictionaries),
but once you see the pattern it's pretty easy to convert between them.

On Thursday, September 18, 2014 7:15:06 AM UTC-7, Mark van der Walle wrote:

That helps a lot thank you. Still it would take a lot of time to write
it first in YAML, test, convert to JSON, test again.

Do you have any small examples I could look at to get some idea?

Regards,
Mark

Senior DevOps Engineer

crowdynews.com
213-B, Friesestraatweg
NL-9743 AD GRONINGEN
The Netherlands
Chamber of Commerce # 02096214

Mail ma...@crowdynews.com <javascript:>
Skype crowdymark

On 18-09-14 15:57, Akilesh K wrote:

Hi,
I could not have a top.sls in json. I had that problem too.

@mark
I have a github repo for where I have both yaml and equivalent json
syntax sls files in different branches. I hope that helps you.
Further I relied a lot on 'http://jsontoyaml.com/' and '
http://yamltojson.com/' and 'jsonlint.com' to get thing right the first
time.

Good luck.

On Thu, Sep 18, 2014 at 6:34 PM, Mark van der Walle <ma...@crowdynews.com
<javascript:>> wrote:
And that is exactly the kind of answer I can't do anything with. I know
YAML and JSON both. My problem is that when you add a JSON renderer add a
bit more docs on how to use it. No there is nothing stopping me from
writing JSON, however there is a lot holding us back.

That YAML is the best supported language does not mean everyone wants to
use it. Salt should help differing types of companies to integrate their
tools and preferences. It's flexibility in allowing people to use their own
language is great.

On a related note. Can the top.sls file be in JSON? I have not found a
way to get that to work. It is not actually something that we really need,
however I would like to do so for consistency.


On Thursday, September 18, 2014 2:51:44 PM UTC+2, Daniel Bryan wrote:

Syntatically, YAML is a superset of JSON[1]. YAML is the dominant
language for SLS files in Salt.

So there's nothing to stop you from filling your state and pillar files
with as much ugly JSON as you want; you're still writing in the first-class
SLS format which has the best support in Salt and is the most clearly
documented.

[1] http://yaml.org/spec/1.2/spec.html#id2759572
--
You received this message because you are subscribed to the Google Groups
"Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to salt-users+...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 9 | next ›
Discussion Overview
groupsalt-users @
postedSep 18, '14 at 12:42p
activeSep 25, '14 at 7:27a
posts9
users5

People

Translate

site design / logo © 2022 Grokbase