Table of Contents

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

string

bundledDependencies

Gets or sets the bundled dependencies.

public Dictionary<string, string>? bundledDependencies { get; set; }

Property Value

Dictionary<string, string>

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

Dictionary<string, string>

description

Gets or sets the package description.

public string? description { get; set; }

Property Value

string

devDependencies

Gets or sets the development dependencies.

public Dictionary<string, string>? devDependencies { get; set; }

Property Value

Dictionary<string, string>

directories

Gets or sets the directory mappings.

public Dictionary<string, string>? directories { get; set; }

Property Value

Dictionary<string, string>

ember

Gets or sets the Ember.js configuration.

public Dictionary<string, string>? ember { get; set; }

Property Value

Dictionary<string, string>

engines

Gets or sets the engine version requirements.

public Dictionary<string, string>? engines { get; set; }

Property Value

Dictionary<string, string>

keywords

Gets or sets the package keywords.

public List<object>? keywords { get; set; }

Property Value

List<object>

license

Gets or sets the license type.

public string? license { get; set; }

Property Value

string

main

Gets or sets the main entry point.

public string? main { get; set; }

Property Value

string

name

Gets or sets the package name.

public string? name { get; set; }

Property Value

string

packageManager

Gets or sets the package manager specification.

public string? packageManager { get; set; }

Property Value

string

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

string

scripts

Gets or sets the npm scripts.

public Dictionary<string, string>? scripts { get; set; }

Property Value

Dictionary<string, string>

type

Gets or sets the module type (e.g. "module" or "commonjs").

public string? type { get; set; }

Property Value

string

version

Gets or sets the package version.

public string? version { get; set; }

Property Value

string

Methods

GetVersionFromDepsOrDevDeps(string)

Returns the version of the specified package from dependencies or devDependencies. Never returns null.

public string GetVersionFromDepsOrDevDeps(string packageName)

Parameters

packageName string

The 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.