ConvertFrom-Json fails to parse project.lock.json
See original GitHub issue$json = gc project.lock.json -Raw
ConvertFrom-Json $json
Expected: PowerShell should be able to parser the json data. Actual: A useless error message which does not tell me what went wrong
ConvertFrom-Json : Cannot process argument because the value of argument "name" is not valid. Change the value of the
"name" argument and run the operation again.
At line:1 char:1
- ConvertFrom-Json $json
- ~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (:) [ConvertFrom-Json], PSArgumentException
- FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
node.js - npm "failed to parse json"
Mostly, this error is due to a syntax error in package.json file. In my case, the opening curly brace for dependencies object in ......
Read more >ConvertFrom-Json - PowerShell
The ConvertFrom-Json cmdlet converts a JavaScript Object Notation (JSON) formatted string to a custom PSObject or Hashtable object that has a property for ......
Read more >ConvertFrom-Json fails to parse project.lock.json
ConvertFrom -Json fails to parse project.lock.json ... Expected: PowerShell should be able to parser the json data. Actual: A useless error message ...
Read more >Why is Convertfrom-Json giving me an error with this file?.md
I get an error: ConvertFrom-Json: Conversion from JSON failed with error: Unexpected character encountered while parsing value: C. Path '', line ...
Read more >Read/Write JSON Files with Node.js
Learn to use fs module to interact with the filesystem; Persist data to a JSON file; Use JSON.parse and JSON.stringify to convert data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Bug is due to empty name for json dictionary entry, which appears to be valid by json standards, issue I believe is when converting to psobject:
Example from the project.lock.json:
“projectFileDependencyGroups”: { “”: [ “System.Management.Automation >= 6.0.0-*” ],
thrown from line 4474 in MshMemberInfo.cs
“Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run the operation again.”
Reproducible with the following simple json:
{ “”: “Test” }
I am uncertain how to proceed further to fix this issue, hopefully this helps.
@DarwinJS You can either modify your json to be compatible with PSObjects, or you will need to modify/create a cmdlet to convert from json into hashtables.