Class PackageJson
- Namespace
- SunamoPackageJson
- Assembly
- SunamoPackageJson.dll
Represents the structure of a package.json file. Property names are lowercase to match JSON serialization format.
public class PackageJson
- Inheritance
-
PackageJson
- Inherited Members
- Extension Methods
Properties
author
Gets or sets the package author.
public string? author { get; set; }
Property Value
bundledDependencies
Gets or sets the bundled dependencies.
public Dictionary<string, string>? bundledDependencies { get; set; }
Property Value
dependencies
Gets or sets the production dependencies. Cannot be a List because it is a JSON object, not an array.
public Dictionary<string, string>? dependencies { get; set; }
Property Value
description
Gets or sets the package description.
public string? description { get; set; }
Property Value
devDependencies
Gets or sets the development dependencies.
public Dictionary<string, string>? devDependencies { get; set; }
Property Value
directories
Gets or sets the directory mappings.
public Dictionary<string, string>? directories { get; set; }
Property Value
ember
Gets or sets the Ember.js configuration.
public Dictionary<string, string>? ember { get; set; }
Property Value
engines
Gets or sets the engine version requirements.
public Dictionary<string, string>? engines { get; set; }
Property Value
keywords
Gets or sets the package keywords.
public List<object>? keywords { get; set; }
Property Value
license
Gets or sets the license type.
public string? license { get; set; }
Property Value
main
Gets or sets the main entry point.
public string? main { get; set; }
Property Value
name
Gets or sets the package name.
public string? name { get; set; }
Property Value
packageManager
Gets or sets the package manager specification.
public string? packageManager { get; set; }
Property Value
private
Gets or sets whether the package is private. Must be nullable so that false is not serialized when it was not originally present.
public bool? @private { get; set; }
Property Value
- bool?
repository
Gets or sets the repository URL.
public string? repository { get; set; }
Property Value
scripts
Gets or sets the npm scripts.
public Dictionary<string, string>? scripts { get; set; }
Property Value
type
Gets or sets the module type (e.g. "module" or "commonjs").
public string? type { get; set; }
Property Value
version
Gets or sets the package version.
public string? version { get; set; }
Property Value
Methods
GetVersionFromDepsOrDevDeps(string)
Returns the version of the specified package from dependencies or devDependencies. Never returns null.
public string GetVersionFromDepsOrDevDeps(string packageName)
Parameters
packageNamestringThe name of the package to look up.
Returns
- string
The version string, or an empty string if the package is not found.
ToString()
Serializes the package.json object to a JSON string, ignoring null properties.
public override string ToString()
Returns
- string
A formatted JSON string representation.