i want to get data to WebPart from the SharePoint list. but some of the data are eg. PeoplePicker or Multiple line of text and I have result shown as:

<div class="ExternalClass87D2C35DDC814159BCA3F4ACC1BFBC35"><p>Normal Text</p></div>

and here comes my question. How i can parse json response from spHttpClient to array, so later i can delete non usuable data?

I'm using the code below to get data

> private _getMultiLineData(): Promise<IDetailsListItem[]> {
>     return this.context.spHttpClient.get(
>     `URL`,
>     SPHttpClient.configurations.v1)
>     .then(response => {
>     return response.json();
>      })
>      .then(jsonResponse => {
>        return jsonResponse.value;
>      }) as Promise<IDetailsListItem[]>;  }
  • Are you asking how to get "Normal Text" out of that returned HTML? If not, please try to explain bit more what is the exact question. – Jussi Palo May 2 '19 at 11:37
  • @JussiPalo pretty much yeah, this is my destination. To be specific i ask how to get into the specific object returned by json so then i can get "normal text" from that returned HTML – KKania May 2 '19 at 11:41
  • @JussiPalo I'm getting from SharePoint List data via spHttpClient, the response is in JSON. When I print it to the WebPart it is (as shown in the question) in html. My problem is, how to get into that specific object to parse it to string so i can later edit it, to have only value i want. – KKania May 2 '19 at 12:15
  • As a side comment, I'd recommend using @pnp/sp library for the queries (pnp.github.io/pnpjs/sp/docs/items), will probably save you lots of headache as you wouldn't need to manually construct REST queries. I assume it will also pretty much answer this question. – Jussi Palo May 2 '19 at 12:26
  • @JussiPalo I'll take a look. Thank You :) – KKania May 2 '19 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.