Skip to content
Advertisement

PHP json_encode to C# Object unable to convert

I have this array of objects that contains some strings and an array of strings that I want to return from my server:

“[{“original_file_name”:”Plain_HAIR.pdf”,”encrypted_file_name”:”UTTSJG13V1EC46J.pdf”,”is_successful”:true,”message”:””,”email”:”[“testuser@gmail.com”]”,”doctype”:”HAIR”}]”

On my local app, I have a class that looks like this:

JavaScript

The issue is that when it comes back to the local app, I get an error saying :

{“Error converting value “[{“original_file_name”:”Plain_HAIR.pdf”,”encrypted_file_name”:”UTTSJG13V1EC46J.pdf”,”is_successful”:true,”message”:””,”email”:”[“testuser@gmail.com”]”,”doctype”:”HAIR”}]” to type ‘System.Collections.Generic.List`1[Uploader.ViewModels.FileUploadResultViewModel]’. Path ”, line 1, position 1521.”}

Am I converting it wrongly or are there some steps missing?

EDIT:

This is how I define the object on the server:

JavaScript

EDIT 2: Showing the method to retrieve the json result

JavaScript

Advertisement

Answer

Update: Final solution was that there was a json_encode too much.

On the line before var res = client.Execute(request);, add this:

JavaScript

This is working:

JavaScript

And surrounding with " is also working

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement