Test

<back to all web services

AllCollectionTypes

import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Poco:
    name: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AllCollectionTypes:
    int_array: Optional[List[int]] = None
    int_list: Optional[List[int]] = None
    string_array: Optional[List[str]] = None
    string_list: Optional[List[str]] = None
    float_array: Optional[List[float]] = None
    double_list: Optional[List[float]] = None
    byte_array: Optional[bytes] = None
    char_array: Optional[List[str]] = None
    decimal_list: Optional[List[Decimal]] = None
    poco_array: Optional[List[Poco]] = None
    poco_list: Optional[List[Poco]] = None
    poco_lookup: Optional[Dict[str, List[Poco]]] = None
    poco_lookup_map: Optional[Dict[str, List[Dict[str, Poco]]]] = None

Python AllCollectionTypes DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/reply/AllCollectionTypes HTTP/1.1 
Host: test.servicestack.net 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	intArray: 
	[
		0
	],
	intList: 
	[
		0
	],
	stringArray: 
	[
		String
	],
	stringList: 
	[
		String
	],
	floatArray: 
	[
		0
	],
	doubleList: 
	[
		0
	],
	byteArray: AA==,
	charArray: 
	[
		
	],
	decimalList: 
	[
		0
	],
	pocoArray: 
	[
		{
			name: String
		}
	],
	pocoList: 
	[
		{
			name: String
		}
	],
	pocoLookup: 
	{
		String: 
		[
			{
				name: String
			}
		]
	},
	pocoLookupMap: 
	{
		String: 
		[
			{
				String: 
				{
					name: String
				}
			}
		]
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	intArray: 
	[
		0
	],
	intList: 
	[
		0
	],
	stringArray: 
	[
		String
	],
	stringList: 
	[
		String
	],
	floatArray: 
	[
		0
	],
	doubleList: 
	[
		0
	],
	byteArray: AA==,
	charArray: 
	[
		
	],
	decimalList: 
	[
		0
	],
	pocoArray: 
	[
		{
			name: String
		}
	],
	pocoList: 
	[
		{
			name: String
		}
	],
	pocoLookup: 
	{
		String: 
		[
			{
				name: String
			}
		]
	},
	pocoLookupMap: 
	{
		String: 
		[
			{
				String: 
				{
					name: String
				}
			}
		]
	}
}