I am trying to parse an entire Json in a simple argument using ARGPARSE library, the thing is that it stops suddenly when it hits different elements inside the son, like "-" and " ".
Here is the test code:
#parse.py
import argparse
parser = argparse.ArgumentParser(description='JSON_test')
parser.add_argument('-contenido', action='store', dest='CONTENIDO',
help='JSON content')
args = parser.parse_args()
C = args.CONTENIDO
print (C)
This is an example of the running code
python parse.py -contenido """{"desde": "2020-03-01","hasta": "2020-03-31","plantas": [{"id": 6,"nombre": "MDS","inversores": [{"id": "Ingeteam 0237","energa": 2152.8070,"pr": 61.5299,"disponibilidad": 81.1770,"factorPlanta": 15.5313}, {"id": "Ingeteam 0538","energa": 2167.5898,"pr": 61.9315,"disponibilidad": 81.0459,"factorPlanta": 15.6381}, {"id": "Ingeteam 0236","energa": 2168.1885,"pr": 61.9511,"disponibilidad": 80.9856,"factorPlanta": 15.6426}, {"id": "Ingeteam 0563","energa": 2206.8702,"pr": 63.0825,"disponibilidad": 80.9455,"factorPlanta": 15.9219}]"""
and finally the error
parse.py: error: unrecognized arguments: 0237,energia: 2152.8070,pr: 61.5299,disponibilidad: 81.1770,factorPlanta: 15.5313}, {id: Ingeteam 0538,energia: 2167.5898,pr: 61.9315,disponibilidad: 81.0459,factorPlanta: 15.6381}, {id: Ingeteam 0236,energia: 2168.1885,pr: 61.9511,disponibilidad: 80.9856,factorPlanta: 15.6426}, {id: Ingeteam 0563,energia: 2206.8702,pr: 63.0825,disponibilidad: 80.9455,factorPlanta: 15.9219}]"
Our architecture wont let us use a file to parse, so that work around won't work :(. What can i do? i've read a lot of SOF posts and i will test them tomorrow but i am thinking that they won't suit this specific problem, our json is very large and we need to run it from a single argument. Thanks in advance!