Search code examples
fluttermediawiki-api

Omitting JSON data from WikiMedia Rest API


I am getting data from WikiMedia Mobile Rest Api. The response is fine and data comes as JSON but there is a problem with the extracted data. There is some CSS content '.mw-parser-output' that i need to cut from the JSON.

See the attached image..mw-parser-output How can i omit this data from JSON.


Solution

  • You can simply use replaceAll on this field during deserialisation:

    final jsonField = "Lorem .mw-parser-output ipsum";
      
    print(jsonField.replaceAll('.mw-parser-output', '')); // prints Lorem  ipsum