ServiceStack.Text | .NET 's fastest JSON , JSV and CSV Text Serializers | JSON Processing library
kandi X-RAY | ServiceStack.Text Summary
kandi X-RAY | ServiceStack.Text Summary
Follow @ServiceStack, view the docs, use StackOverflow or Customer Forums for support.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ServiceStack.Text
ServiceStack.Text Key Features
ServiceStack.Text Examples and Code Snippets
Community Discussions
Trending Discussions on ServiceStack.Text
QUESTION
We want to get the UserName from the ServiceStack session, but we find that the backslashes in the UserName are not deserialized as expected. The UserName has this format 'domainname\username' and serialized in a jwt token this looks like:
...ANSWER
Answered 2021-Nov-05 at 16:10The issue is due to enumerating a JsonObject
didn't return the same escaped string value as indexing it which has been resolved from this commit.
This change is available from v5.12.1+ that's now available on MyGet.
QUESTION
In search for a scripting language for my Unity application I came across SharpScript and the example project (https://github.com/ServiceStack/script-unity) that worked fine. However the example project is more than 2 years old so the language and its implementation had went a long way since then.
So I have updated all the SharpScript related dlls to their latest versions to get the latest version and now my project still works in the editor but it stopped working when built with IL2CPP + .Net4.x Unity settings. The error I'm getting upon the start is this:
...ANSWER
Answered 2021-Apr-29 at 14:34This runtime Exception occurs when trying to access the .NETs ConfigurationManager
class which is now being caught from this commit.
This change is available from the latest v5.11.1+ that's now available on MyGet.
QUESTION
I've got following setup: C#, ServiceStack, MariaDB, POCOs with objects and structs, JSON.
The main question is: how to use ServiceStack to store POCOs to MariaDB having complex types (objects and structs) blobbed as JSON and still have working de/serialization of the same POCOs? All of these single tasks are supported, but I had problems when all put together mainly because of structs.
... finally during writing this I found some solution and it may look like I answered my own question, but I still would like to know the answer from more skilled people, because the solution I found is a little bit complicated, I think. Details and two subquestions arise later in the context.
Sorry for the length and for possible misinformation caused by my limited knowledge.
Simple example. This is the final working one I ended with. At the beginning there were no SomeStruct.ToString()/Parse()
methods and no JsConfig
settings.
ANSWER
Answered 2021-Apr-02 at 09:19ServiceStack treats structs like a single scalar value type, just like most of the core BCL Value Types (e.g. TimeSpan
, DateTime
, etc). Overloading the Parse()
and ToString()
methods and Struct's Constructor
let you control the serialization/deserialization of custom structs.
Docs have been corrected. Structs use
Parse
whilst classes useParseJson/ParseJsv
If you want to serialize a models properties I'd suggest you use a class
instead as the behavior you're looking for is that of a POCO DTO.
If you want to have structs serailized as DTOs in your RDBMS an alternative you can try is to just use JSON.NET for the complex type serialization, e.g:
QUESTION
I have some JSON text and I want to deserialize it into a Dictionary
. ServiceStack.Text does that no problem, until there are brackets inside the string values. Then it decides to deserialize that string, as if it was JSV (ServiceStack's format, similar to json but without quotes).
Here is a simplified JSON example:
...ANSWER
Answered 2021-Feb-26 at 23:25ServiceStack.Text's JSON Serializer is primarily designed for deserializing JSON into typed POCOs.
For deserializing artibtrary JSON into untyped collections it's recommended to use JS Utils instead, e.g:
QUESTION
I have a case where the ServiceStack JSON serializer fails to deserialize, and where Newtonsoft's JSON.NET manages to do so. I have not found a clear-cut way to replace the default serializer with JSON.NET, so its global and for all classes.
JsConfig.SerializeFn
I guess works, but it is per class, and I want for all classes, globally.
How do I do that?
Background
I am using the ServiceStack.Messaging.Redis
and Redis as an MQ solution. We use this approach to sending messages:
ANSWER
Answered 2020-Aug-21 at 10:18ServiceStack.Redis has a hard dependency on ServiceStack.Text for its object Serialization, it doesn't support global substitution to use an alternative JSON Serailizer.
One workaround for sending arbitrary payloads in messages is to send a serialized JSON in a string Result
property, which you could use JSON.NET to de/serialize.
Another potential workaround is using the FromObjectDictionary Reflection Utils to convert the Object Dictionary back into the typed DTO, e.g:
QUESTION
There is an example of a simple ServiceStack F# application for .NET 4.5:
...ANSWER
Answered 2020-Aug-21 at 15:36I've added an empty .NET Core 3.1 Project Template that you can download in a new empty directory using the x dotnet tool which will let you start a new F# .NET Core 3.1. ServiceStack Project with:
QUESTION
I am currently using ServiceStack.Text to serialize CSV from a list of objects. I have a model:
...ANSWER
Answered 2020-Jun-11 at 14:00You can use the order option. Ex: [DataMember(Order = 0)]
the documentation is at this link: https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-member-order
QUESTION
I had a plan to connect to a JSON-based API using ServceStack's Routing features for C#. It seems that I get a '422 Unprocessable Entity' when attempting to do so when, in reality I'm supposed to be getting a JSON response. This error message is interesting though, since it repeats itself multiple times over (8 times exact) with the message Could not parse Error ResponseStatus ErrorResponse System.IndexOutOfRangeException: Index was outside the bounds of the array. Full stack trace below.
I've tried many configurations, and there is one that 'works' but removes one of the key needs of the way this route is set up. In this project, I use ICacheClient
to save a session key for 5 minutes, so I don't always need to call the API every time I need it. Since ServiceStack uses injection to set my instance of ICacheClient
, it must be public. However, if it is public I get that 422 error, but if it isn't public I get a NullPointer because it's reference cannot be set by ServiceStack.
Here's my current setup:
AppHost.cs
...ANSWER
Answered 2020-Jun-05 at 16:11The problem was caused by the following issue: - The 3rd-party provider automatically adds "Bearer" before your token.
This snippet:
QUESTION
I am using a valid license key. But I keep getting this error:
...ANSWER
Answered 2020-Feb-06 at 12:42I believe the version of ServiceStack you are using was built with a different version of System.Runtime.CompilerServices.Unsafe than what you are using in your Test project and because bindingredirect are not working in this context. See Does redirecting assembly binding work for unit testing with a test runner?
As a workaround, you can try changing System.Runtime.CompilerServices.Unsafe in Nuget Package Manager to 4.5.2.
This version matches the missing assembly, Version=4.0.4.1.
Edit: If you are using NUnit 3 in your NUnit build step, you can then specify "Path to application configuration file: " to point to your app.config. This should solve the root problem and let you use the most current version of your Nuget packages (since the correct bindingRedirects will then be applied).
QUESTION
I am working with large json files and memory is a concern. I would like to read one object into memory at a time from file. Is this possible?
In ServiceStack.Text docs it says there is an API using reader/stream
But I can't see how to get that working. The files are too large to deserialize in one go. Is it possible to handle this scenario with SS?
Thanks
...ANSWER
Answered 2020-Jan-08 at 14:51No you'll want to use a streaming JSON parser like System.Text.Json Utf8JsonReader, this is the example on System.Text.Json introductory page:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ServiceStack.Text
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page