How to use json2typescript - 10 common examples

To help you get started, we’ve selected a few json2typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github harry-sm / BittrexRx / src / model / Balance.ts View on Github external
import { JsonProperty, Any } from 'json2typescript';

export class Balance {
	@JsonProperty('Currency', String, false)
	public Currency: string = undefined;

	@JsonProperty('Balance', Number, false)
	public Balance: number = undefined;

	@JsonProperty('Available', Number, false)
	public Available: number = undefined;

	@JsonProperty('Pending', Number, false)
	public Pending: number = undefined;

	@JsonProperty('CryptoAddress', Any, false)
	public CryptoAddress: string | null = undefined;

	// Requested?: boolean;
	// Uuid: string | null;
}
github harry-sm / BittrexRx / src / core / bittrex-rx-socket-client.ts View on Github external
private convert(data: any, dataType: Model.ClassType): T {
		const jsc: JsonConvert = new JsonConvert();
		jsc.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL; // never allow null

		return jsc.deserialize(data, dataType);
	}
github harry-sm / BittrexRx / src / core / bittrex-rx-socket-client.ts View on Github external
private convert(data: any, dataType: Model.ClassType): T {
		const jsc: JsonConvert = new JsonConvert();
		jsc.valueCheckingMode = ValueCheckingMode.DISALLOW_NULL; // never allow null

		return jsc.deserialize(data, dataType);
	}
github harry-sm / BittrexRx / src / core / bittrex-rx-client.ts View on Github external
constructor() {
		CloudflareAuthenticator.init();

		this.http = new HttpClient();
		this.requestOptions = {
			agent: false,
			headers: {},
			method: 'GET'
		};
		this.jsc = new JsonConvert();
	}
github harry-sm / BittrexRx / src / model / CryptoCurrency.ts View on Github external
import { JsonProperty, Any } from 'json2typescript';

export class Currency {
	@JsonProperty('Currency', String, false)
	public Currency: string = undefined;

	@JsonProperty('CurrencyLong', String, false)
	public CurrencyLong: string = undefined;

	@JsonProperty('MinConfirmation', Number, false)
	public MinConfirmation: number = undefined;

	@JsonProperty('TxFee', Number, false)
	public TxFee: number = undefined;

	@JsonProperty('IsActive', Boolean, false)
	public IsActive: boolean = undefined;

	@JsonProperty('CoinType', String, false)
	public CoinType: string = undefined;

	@JsonProperty('BaseAddress', Any, true)
	public BaseAddress: string | null = undefined;

	@JsonProperty('Notice', Any, true)
	public Notice?: any = undefined;
}
github harry-sm / BittrexRx / src / model / OrderBookItem.ts View on Github external
private jsc: JsonConvert = new JsonConvert();

	public serialize(data: OrderBookOrderItem[]): any {
		return data;
	}

	public deserialize(data: any[]): OrderBookOrderItem[] {
		return data.map((item: any) => {
			return this.jsc.deserialize(item, OrderBookOrderItem);
		});
	}
}

export class OrderBook {
	@JsonProperty('buy', OrderItemConverter, false)
	public buy?: OrderBookOrderItem[] = undefined;

	@JsonProperty('sell', OrderItemConverter, false)
	public sell?: OrderBookOrderItem[] = undefined;
}

export class OrderBookOrderItem {
	@JsonProperty('Quantity', Number, false)
	public Quantity: number = undefined;

	@JsonProperty('Rate', Number, false)
	public Rate: number = undefined;
}
github harry-sm / BittrexRx / src / model / Transaction.ts View on Github external
import { JsonProperty } from 'json2typescript';
import { DateTime } from '../converter';

export class Transaction {
	@JsonProperty('Id', Number, false)
	public Id: number = undefined;

	@JsonProperty('Amount', Number, false)
	public Amount: number = undefined;

	@JsonProperty('Currency', String, false)
	public Currency: string = undefined;

	@JsonProperty('Confirmations', Number, false)
	public Confirmations: number = undefined;

	@JsonProperty('LastUpdated', DateTime, false)
	public LastUpdated: DateTime = undefined;

	@JsonProperty('TxId', String, false)
	public TxId: string | null = undefined;

	@JsonProperty('CryptoAddress', String, false)
	public CryptoAddress: string | null = undefined;
github harry-sm / BittrexRx / src / model / ExchangeState.ts View on Github external
@JsonProperty('Nounce', Number, false)
	public Nounce: number = undefined;

	@JsonProperty('Buys', OrderBookOrderConverter, false)
	public Buys: OrderBookOrderStream[] = undefined;

	@JsonProperty('Sells', OrderBookOrderConverter, false)
	public Sells: OrderBookOrderStream[] = undefined;

	@JsonProperty('Fills', OrderBookOrderFillsConverter, false)
	public Fills: OrderBookOrderFillsStream[] = undefined;
}

export class OrderBookOrderStream {
	@JsonProperty('Type', Number, false)
	public Type: number = undefined;

	@JsonProperty('Quantity', Number, false)
	public Quantity: number = undefined;

	@JsonProperty('Rate', Number, false)
	public Rate: number = undefined;
}
export class OrderBookOrderFillsStream {

	@JsonProperty('OrderType', String, false)
	public OrderType: string = undefined;

	@JsonProperty('Quantity', Number, false)
	public Quantity: number = undefined;
github harry-sm / BittrexRx / src / model / OrderHistoryOrderItem.ts View on Github external
@JsonProperty('Limit', Number, false)
	public Limit: number = undefined;

	@JsonProperty('Quantity', Number, false)
	public Quantity: number = undefined;

	@JsonProperty('QuantityRemaining', Number, false)
	public QuantityRemaining: number = undefined;

	@JsonProperty('Commission', Number, false)
	public Commission: number = undefined;

	@JsonProperty('Price', Number, false)
	public Price: number = undefined;

	@JsonProperty('PricePerUnit', Number, false)
	public PricePerUnit: number = undefined;

	@JsonProperty('IsConditional', Boolean, false)
	public IsConditional: boolean = undefined;

	@JsonProperty('Condition', String, false)
	public Condition: string = undefined;

	@JsonProperty('ConditionTarget', Any, false)
	public ConditionTarget: undefined = undefined;

	@JsonProperty('ImmediateOrCancel', Boolean, false)
	public ImmediateOrCancel: boolean = undefined;

	@JsonProperty('Closed', DateTime, false)
	public Closed: Date = undefined;
github harry-sm / BittrexRx / src / model / OpenOrder.ts View on Github external
import { JsonProperty, Any } from 'json2typescript';
import { DateTime } from '../converter';
import { OrderType } from '../converter/order-type';
import { OrderTypeValue } from '../enum/OrderTypeValue';

export class OpenOrder {
	@JsonProperty('Uuid', Any, false)
	public Uuid: string | undefined = undefined;

	@JsonProperty('OrderUuid', String, false)
	public OrderUuid: string = undefined;

	@JsonProperty('Exchange', String, false)
	public Exchange: string = undefined;

	@JsonProperty('OrderType', OrderType, false)
	public OrderType: OrderTypeValue = undefined;

	@JsonProperty('Quantity', Number, false)
	public Quantity: number = undefined;

	@JsonProperty('QuantityRemaining', Number, false)
	public QuantityRemaining: number = undefined;

	@JsonProperty('Limit', Number, false)
	public Limit: number = undefined;

	@JsonProperty('CommissionPaid', Number, false)
	public CommissionPaid: number = undefined;

	@JsonProperty('Price', Number, false)
	public Price: number = undefined;

json2typescript

Provides TypeScript methods to map a JSON object to a JavaScript object on runtime

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis