-
Notifications
You must be signed in to change notification settings - Fork 0
Dump Utils
In ServiceStack.Text's JsvFormatter class are extension methods which recursively dumps all the public properties of any type into a human readable pretty formatted string.
string Dump<T>(this T instance);
string SerializeAndFormat<T>(this T instance);
void PrintDump<T>(this T instance);The Dump and SerializeAndFormat methods achieve the same result, where the logically named but lengthier SerializeAndFormat describes exactly what it does, although most of the time we don't care and are happy to use the shortened Dump to mean the same thing.
There's also a convenient PrintDump extension which just writes the output to the Console to provide a wrist-friendly API for a common use-case.
After importing the ServiceStack.Text namespace you can view the values of all fields as seen in the following example:
var model = new TestModel();
model.PrintDump();{
Int: 1,
String: One,
DateTime: 2010-04-11,
Guid: c050437f6fcd46be9b2d0806a0860b3e,
EmptyIntList: [],
IntList:
[
1,
2,
3
],
StringList:
[
one,
two,
three
],
StringIntMap:
{
a: 1,
b: 2,
c: 3
}
}As this feature has come in super useful for debugging, it's also included it as part of the JSV endpoint by simply appending &debug anywhere in the request’s query string.
Even if you don’t use the new JSV endpoint you can still benefit from it by instantly being able to read the data provided by your web service. Here are some live examples showing the same web services called from the XML and JSV endpoint that shows the difference in readability:
- Why ServiceStack?
- What is a message based web service?
- Advantages of message based web services
- Why remote services should use separate DTOs
- Getting Started
- Reference
- Clients
- Formats
- View Engines 4. Razor & Markdown Razor
- Hosts
- Security
- Advanced
- Configuration options
- Access HTTP specific features in services
- Logging
- Serialization/deserialization
- Request/response filters
- Filter attributes
- Concurrency Model
- Built-in caching options
- Built-in profiling
- Form Hijacking Prevention
- Auto-Mapping
- HTTP Utils
- Virtual File System
- Config API
- Physical Project Structure
- Modularizing Services
- MVC Integration
- Plugins 3. Request logger 4. Swagger API
- Tests
- Other Languages
- Use Cases
- Performance
- How To
- Future