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 answers
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
- Handling both JSON and form values in POST request body with unknown values in Golang
- JSON Body is Not Passing Certain Strings
- Custom rewriter for json
- TypeScript: Type checking while parsing an arbitrary JSON that is typed/
- I dont understand what to do with: System.Text.Json.JsonException: 'The JSON value could not be converted to System.Collections.Generic.IEnumerable`1
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Dynamic Nested Multi-Dimensional Arrays in Rust
- Creating bar chart in FastAPI
- How to encode ttsJson data?
- Trying to get the id of the last element in my json file through an api
- How to give index id to my uploaded json file in FastAPI?
- JQ JSON - Values to Array
- Spring boot JSON parse error: Unexpected character error
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Sigma.JS custom rendering
Related Questions in YAML
- Get current Timestamp in CET format and concatenate with string in yml file
- How to generate random item from json file in yaml code for artilliery load testing?
- Github Actions/variable-mapper : Error: Unexpected token *** in JSON
- Traverse through nodes with a path and change a value in a YAML File using yaml-cpp
- JSYAML custom schema for INT
- Deploy Docker Image into AKS cluster using Azure Release Pipelines with the parameters like clustername, acr, resourcegroup
- Allow AWS API Gateway to return YAML format, when a specific JSON property equals YAML
- Does Golang Yaml Unmarshal Support accessing nested yaml through struct tags?
- How to escape angle brackets in YAML?
- Mark OpenAPI schema enum value as deprecated
- yaml.safe_load removes whitespaces if also contains a line break
- Convert Azure desired state configs (DSC) powershell scripts to JSON or YAML
- GCP Cloud Build deploying a scheduler job
- I'm having issues with YAML skipping a job, based on a parameter value passed into the YAML
- Ansible role variable is not defined
Related Questions in JSON.NET
- Ignore NULL values in JsonConvert.Deserialize or JToken.Parse
- JsonConvert replace serialized non-object values with type names
- Adding a new JSON property to a class from a Nuget
- How to serialize object to JSON format which inherits IList and has other properties
- JsonConvert.DeserializeObject with different property types needs to continue even after failing but collect the list of errors
- How to get parent node id from child node id in JSON
- Empty Object don't override in Merge using JSON.net
- Get ASP.NET Core 8 MVC controller to return JSON properties unchanged without lowercasing property names
- Serializing generic class with Newtonsoft without encapsulating inner type
- Generate Custom JSON Schema using Newtonsoft.Json.Schema.Generation
- .NET JSON Property custom required logic
- .NET Framework Newtsonsoft json customize required exception message
- After upgrading from .NET 5 to .NET 7 and removing Newtonsoft.Json, DateTime values in API responses are different
- Map JSON string array of headers and nested array of results to C# Generic
- How to deserialize json to C# class with arbitrary number of values and attributes
Related Questions in JSON5
- Parsing error: Error while parsing config - JSON5: invalid character ?? at 1:1
- Variant types in JSON5 (serde)
- Column headers skipped horizontally when using sqldump-to node js package: SyntaxError: JSON5: invalid character 'U' at 1:93
- Is there a JSON with comments to YAML converter?
- python json5 and json package inconsistent deal with surrogate pair
- Parse json files with comments? (keybindings.json)
- How to add JSON5 schemas in VS Code?
- SyntaxError: JSON5: invalid character 'm' at 3:1
- How to get only first element in list contained in string?
- Nuxt asyncData returns empty array for a json5 file with Nuxt Content
- TypeError: JSON5.parse is not a function
- ValueError exception "п" while reading .json file with json5
- How to import a JSON5 file (as one can regular JSON) in Typescript?
- Using variables with YAML in Node.js
- Parcel: JSON5: invalid character '\'
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?
Popular Tags
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)
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.