Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Using TReader help
Mon, Nov 4 2019 10:18 PMPermanent Link

Paul Coshott

Avatar

Hi All,

We have a REST service for logging a user in and this is working with no problems. But if the login is rejected, I'm not sure how to read the json format that the error is in.

It looks like this:

{ "error":
 {"code":"Exception","message":"Invalid user name or password."}
}

I just want the message part. Can anyone tell me how to use a TReader to get that?

Thanks,
Paul
Tue, Nov 5 2019 4:39 AMPermanent Link

Walter Matte

Tactical Business Corporation

There is a JSON parsing unit in the Component forum.  That can be used as an alternative to the TReader,

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_components&page=1&msg=152#152

Walter


Paul Coshott wrote:

Hi All,

We have a REST service for logging a user in and this is working with no problems. But if the login is rejected, I'm not sure how to read the json format that the error is in.

It looks like this:

{ "error":
 {"code":"Exception","message":"Invalid user name or password."}
}

I just want the message part. Can anyone tell me how to use a TReader to get that?

Thanks,
Paul



Attachments: JsonParse.png
Tue, Nov 5 2019 8:52 AMPermanent Link

Paul Coshott

Avatar

Thanks Walter. I'll check it out.

Cheers,
Paul


Walter Matte wrote:

There is a JSON parsing unit in the Component forum.  That can be used as an alternative to the TReader,

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_components&page=1&msg=152#152
Wed, Nov 6 2019 4:09 AMPermanent Link

Matthew Jones

Paul Coshott wrote:

> { "error":
>   {"code":"Exception","message":"Invalid user name or password."}
> }

Define a class with a published error property which is an object with the two string properties of "code" and "message".
I think it will then be automatic.

--

Matthew Jones
Wed, Nov 6 2019 5:07 AMPermanent Link

Walter Matte

Tactical Business Corporation

Also see the example that comes with EWB - Persistence.

Searching forum you will see Matthew's JSONList.zip where he users TReader and TWriter.

Walter
Image