1

I am being asked to write a typescript rest api that consumes an old soap api from a vendor and returns it for internal use. I have not touched javascript in years, so I figure this is a really simple question but I can not seem to solve it.

I have a JSON string which I then parse with JSON.parse(JSONstring) and I get the following object:

{ '$': { TimeStamp: '7/02/2019 11:20AM GMT-07:00',
 version: '1.0',
 WFCVersion: '8.1.3.1531' }, Response: [ { '$': [Object], Schedule: [Array] } ] }

To get that result I am doing: var key1 = JSONbody['Kronos_WFC'] or JSONbody.Kronos_WFC. I am able to get the response with JSONbody.Kronos_WFC.Response but for the life of me I can not get to the Schedule which is what I need

I tried multiple version of JSONbody.Kronos_WFC.Response.Schedule or JSONbody.Kronos_WFC.Schedule All I get is undefined.

1 Answer 1

1

Try JSONbody.Kronos_WFC.Response[0].Schedule The square brackets in the Response indicate a list or array, and [0] will get the first object in the array.

Sign up to request clarification or add additional context in comments.

2 Comments

OMg thank you I knew I was just missing something stupid! Sometimes you just get frustrated with simple things
You're welcome. If this answer solved your problem, please mark it as the correct answer. Welcome to stackoverflow :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.