There are a number of JSON variants that accept comments (JSON with comments, JSON 5, etc.). There are plenty of tools available that convert JSON to YAML and vice versa. Does there exist such a converter from JSON to YAML that (1) accepts JSON comments and (2) converts these comments to YAML comments?
Is there a JSON with comments to YAML converter?
309 Views Asked by Scott Deerwester At
2
There are 2 best solutions below
2
rolovargas
On
I use an app called DevToys (https://devtoys.app/), which has this functionality - as well as many other very useful other tools. Very highly recommended!
This is a screenshot from their site with what you need: https://devtoys.app/img/screenshots/json_yaml.png
Related Questions in JSON
- getting undefined while iterating json
- How can I serialize a numpy array while preserving matrix dimensions?
- What is best way to check if any of the property of object is null or empty?
- How to query JSON data according to JSON array's size with Spark SQL?
- Extracting data from json_decode with lat and lng geolocation
- Convert JSON.gz to JSON in node js
- How do I get the type to convert to when deserializing from Jackson
- Escape dot in jquery validate plugin
- Are allOf and properties keywords interchangeable?
- Sort continents by amount of countries
- Is there a data format lighter than json?
- Object of class CS_REST_Wrapper_Result could not be converted to string in CAMPAIGN MONITOR
- How to read JSON data from a web server running PHP and MySQL?
- Parse Nsmutabledictionary and extract value
- Handle empty JSON values in Java
Related Questions in YAML
- PyYAML variables in multiline
- What does the dot mean in Symfony service names?
- Set-like alternative for yaml files
- How do I convert a python list to simple YAML?
- Saving order in ruamel.yaml
- REST API design for cloning a resource
- Pythonic way to get value defined or not defined in yaml
- how to install new nodejs modules to expressjs project?
- Can I use hiera with a YAML backend to combine arrays?
- Should YamlConfiguration objects be closed?
- behat yml extract urlbase to suite level
- Yaml syntax to create this array
- Go Yaml Interpretation Example
- Scala: Parse a Yaml file using SnakeYaml
- YAML file do integer calculation
Related Questions in JSON.NET
- Deserialising mimekit.MimeMessage Object
- Deserialize JSON Data automatically when using timestamp
- Why can't Json.Net 6 deserialize a T as a generic list in a dynamic object? (worked in version 5)
- Json.Net: Html Helper Method not regenerating
- How to convert json with jarray inside to a object
- JSON result from PipeDrive API does not deserialize
- Self Hosted WCF Rest service ERROR : Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported
- I can't manage to save my serialized .json in wp8.1
- extract a value from returned json
- Serialize Tweetinvi using JsonConvert.SerializeObject
- Unable to use JSONpath type querying
- JsonConverter: Get parent object in ReadJson, without $refs
- Prevent JSON.Net custom converter from converting child objects
- ASP.NET Web API: JSON Serializing Circular References
- json view in c# is adding additional json properties in json schema List
Related Questions in JSON5
- Variant types in JSON5 (serde)
- Nuxt asyncData returns empty array for a json5 file with Nuxt Content
- How to get only first element in list contained in string?
- TypeError: JSON5.parse is not a function
- Parcel: JSON5: invalid character '\'
- How do I parse this non-standard JSON format?
- Can the Jackson parser be used to parse JSON5?
- python json5 and json package inconsistent deal with surrogate pair
- Error while parsing config - JSON5: invalid end of input at 1:1 at syntaxError
- Requiring a JSON with comments in node.js
- Parsing json5/js object literals in Ada
- Error while parsing JSON - Unexpected EOF at line 1 column 2 of the JSON5 data. when I npm run build
- Safely parsing a JSON string with unquoted keys
- How to import a JSON5 file (as one can regular JSON) in Typescript?
- ValueError exception "п" while reading .json file with json5
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
As of YAML 1.2.0 (Jul 21, 2009), YAML is a superset of JSON. Thus, technically, as long as the commenting style is YAML-compliant (using
#not//etc.), all "JSON variants that accept comments" by themselves are already valid YAML documents.To alter the styling of some YAML (including JSON) content, you only need to find an appropriate (general) YAML(-only) processor that preserves (all) comments.
Here's one example using mikefarah/yq v4.35.1 (not to be confused with kislyuk/yq of the same name which does not preserve comments). With a sample
input.jsoncontainingyou can remove the JSON-styling on all levels using the filter
... style = "":As you can see, four comments get lost: the ones before a first key or item, the one after the last object item, and the one inline with the last closing brace. Examine your use-case, and/or consider extending the filter with some comment operators offered by yq. For example, you could add the last one missing by combining the
line_commentwith thefoot_commentfor the document-level only:Regarding mikefarah/yq specifically, note that the current version (v4.35.1) cannot read a JSON input where an object field's key and the subsequent colon are on separate lines (so you'd also expect comments to live in between):
Also see https://yaml.org/ which has a long list of YAML processors and language frameworks. Some of them also handle comments, so try them out as one of them may just exactly fit your commenting scenario.