Skip to content

Test-Json cmdlet (JSON lint/validator) #4220

Description

Placeholder for now as I follow up on some customer scenarios: it would be really nice to have a cmdlet that could validate JSON before it's used as input. I'd expect for something like this to already exist in Newtonsoft.Json.

IMHO, it's a nice-to-have for 6.0.0 depending on how we're looking with HighPriority over the next couple months. If not, we could move it out to 6.1.0 without a real problem.

Also, this would require an RFC.

Activity

  1. added this to the milestone on Jul 11, 2017
  2. changed the title [-]Test-Json cmdlet (JSON lint)[/-] [+]Test-Json cmdlet (JSON lint/validator)[/+] on Jul 11, 2017
  3. rkeithhill commented on Jul 11, 2017

    @rkeithhill
    Collaborator

    Along these lines, how about a Test-Xml / Format-Xml set of cmdlets? These are implemented in PSCX in C# and could probably be ported over now that .NET Core 2 has support for XML Schema. The Test-Xml cmdlet's utility is fairly self-evident but perhaps that is less so with Format-Xml. The latter command is very handy when you have an XML file that is a single line and 4000 chars wide. :-) It is also handy when attributes are scattered about. A formatter can also put attributes on a new line. In general it makes the XML output easier to read e.g.:

    gc foo.xml
    <?xml version="1.0"?><doc><assembly><name>VBFormsApp</name></assembly><members></members></doc>
    

    becomes:

    format-xml foo.xml
    <?xml version="1.0"?>
    <doc>
      <assembly>
        <name>VBFormsApp</name>
      </assembly>
      <members></members>
    </doc>
    
  4. scotthardwick commented on Jan 10, 2018

    @scotthardwick

    I would also love to see a Test-Json, Test-XML, and Format-XML as part of baseline Powershell. Looks like the Test-Json is well underway

  5. added a commit that references this issue on Mar 26, 2018
    1b745f6
  6. added a commit that references this issue on Apr 24, 2018
    56293f5
  7. added a commit that references this issue on Aug 6, 2026
    3ab5c41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions