Parse Quads as returned by JsonLD.
490407
public function parse($graph, $data, $format = 'jsonld', $baseUri = null)
    {
        parent::checkParseParams($graph, $data, $format, $baseUri);

        foreach ($data as $quad) {
            $subject = (string)$quad->getSubject();

            if ('_:' === substr($subject, 0, 2)) {
                $subject = $this->remapBnode($subject);
            }

            $predicate = (string)$quad->getProperty();

            if ($quad->getObject() instanceof IRI) {
                $object = [
                    'type' => 'uri',
                    'value' => (string)$quad->getObject()
                ];

                if ('_:' === substr($object['value'], 0, 2)) {
                    $object = [
                        'type' => 'bnode',
                        'value' => $this->remapBnode($object['value'])
                    ];
                }
            } else {
                $object = [
                    'type' => 'literal',
                    'value' => $quad->getObject()->getValue()
                ];

                if ($quad->getObject() instanceof LanguageTaggedString) {
                    $object['lang'] = $quad->getObject()->getLanguage();
                } else {
                    $object['datatype'] = $quad->getObject()->getType();
                }
            }

            $this->addTriple($subject, $predicate, $object);
        }
    }
1154075
public Object normalize(Map<String, Object> dataset) throws JsonLdError {
        // create quads and map bnodes to their associated quads
        final List<Object> quads = new ArrayList<Object>();
        final Map<String, Object> bnodes = newMap();
        for (String graphName : dataset.keySet()) {
            final List<Map<String, Object>> triples = (List<Map<String, Object>>) dataset
                    .get(graphName);
            if (JsonLdConsts.DEFAULT.equals(graphName)) {
                graphName = null;
            }
            for (final Map<String, Object> quad : triples) {
                if (graphName != null) {
                    if (graphName.indexOf("_:") == 0) {
                        final Map<String, Object> tmp = newMap();
                        tmp.put("type", "blank node");
                        tmp.put("value", graphName);
                        quad.put("name", tmp);
                    } else {
                        final Map<String, Object> tmp = newMap();
                        tmp.put("type", "IRI");
                        tmp.put("value", graphName);
                        quad.put("name", tmp);
                    }
                }
                quads.add(quad);

                final String[] attrs = new String[] { "subject", "object", "name" };
                for (final String attr : attrs) {
                    if (quad.containsKey(attr) && "blank node"
                            .equals(((Map<String, Object>) quad.get(attr)).get("type"))) {
                        final String id = (String) ((Map<String, Object>) quad.get(attr))
                                .get("value");
                        if (!bnodes.containsKey(id)) {
                            bnodes.put(id, new LinkedHashMap<String, List<Object>>() {
                                {
                                    put("quads", new ArrayList<Object>());
                                }
                            });
                        }
                        ((List<Object>) ((Map<String, Object>) bnodes.get(id)).get("quads"))
                                .add(quad);
                    }
                }
            }
        }

        // mapping complete, start canonical naming
        final NormalizeUtils normalizeUtils = new NormalizeUtils(quads, bnodes,
                new UniqueNamer("_:c14n"), opts);
        return normalizeUtils.hashBlankNodes(bnodes.keySet());
    }
1301360
def _parse_json(self, jstring=None):
        """"""

        # Argument error checking.
        assert jstring is not None

        result = None

        try:
            result = json.loads(jstring)
        except (ValueError) as exception:
            msg = 'Unable to convert JSON string to Python data structure.'
            raise APIDataException(exception, jstring, msg)

        return result
667077
def eidos_process_jsonld():
    """"""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    eidos_json = body.get('jsonld')
    ep = eidos.process_json_str(eidos_json)
    return _stmts_from_proc(ep)
1286579
def parse(self, data):
        """"""

        ASNlist = []
        for line in data.splitlines()[1:]:
            line = plain_str(line)
            if "|" not in line:
                continue
            asn, ip, desc = [elt.strip() for elt in line.split('|')]
            if asn == "NA":
                continue
            asn = "AS%s" % asn
            ASNlist.append((ip, asn, desc))
        return ASNlist
1204923
def parse(out):
    '''
    
    '''
    jsonret = []
    in_json = False
    for ln_ in out.split('\n'):
        if '{' in ln_:
            in_json = True
        if in_json:
            jsonret.append(ln_)
        if '}' in ln_:
            in_json = False
    return salt.utils.json.loads('\n'.join(jsonret))
369785
def read_jsonld():
    
    _d = {}

    try:
        # Find a jsonld file in cwd. If none, fallback for a json file. If neither found, return empty.
        _filename = [file for file in os.listdir() if file.endswith(".jsonld")][0]
        if not _filename:
            _filename = [file for file in os.listdir() if file.endswith(".json")][0]

        if _filename:
            try:
                # Load and decode
                _d = demjson.decode_file(_filename, decode_float=float)
                logger_jsons.info("Read JSONLD successful: {}".format(_filename))
            except FileNotFoundError as fnf:
                print("Error: metadata file not found: {}".format(_filename))
                logger_jsons.error("read_jsonld: FileNotFound: {}, {}".format(_filename, fnf))
            except Exception:
                try:
                    _d = demjson.decode_file(_filename, decode_float=float, encoding="latin-1")
                    logger_jsons.info("Read JSONLD successful: {}".format(_filename))
                except Exception as e:
                    print("Error: unable to read metadata file: {}".format(e))
                    logger_jsons.error("read_jsonld: Exception: {}, {}".format(_filename, e))
        else:
            print("Error: metadata file (.jsonld) not found in LiPD archive")
    except Exception as e:
        print("Error: Unable to find jsonld file in LiPD archive. This may be a corrupt file.")
        logger_jsons.error("Error: Unable to find jsonld file in LiPD archive. This may be a corrupt file.")
    logger_jsons.info("exit read_json_from_file")
    return _d
727577
def asjsonld(self):
        """"""
        source = {}
        if self.__source__:
            source.update(self.__source__)
        source.update(asjsonld(self))
        return source
136181
def coords_from_query(query):
    """"""
    try:
        coords = json.loads(query)
    except ValueError:
        vals = re.split(r'[,\s]+', query.strip())
        coords = [float(v) for v in vals]
    return tuple(coords[:2])
148924
def parse_query(cls, query):
        """"""
        if not query: return {}

        d = {}
        # https://docs.python.org/2/library/urlparse.html
        for k, kv in urlparse.parse_qs(query, True, strict_parsing=True).items():
            #k = k.rstrip("[]") # strip out php type array designated variables
            if len(kv) > 1:
                d[k] = kv
            else:
                d[k] = kv[0]

        return d
892860
def parse_link_attributes(self, some_json):
        ''''''
        try:
            return json.loads(some_json)
        except ValueError:
            print('Invalid JSON argument: {0}'.format(some_json))
        return {}
522245
def coords_from_query(query):
    """"""
    try:
        coords = json.loads(query)
    except ValueError:
        query = query.replace(',', ' ')
        vals = query.split()
        coords = [float(v) for v in vals]
    return tuple(coords[:2])
1001333
def quad_info(name, quad, pretty):
    ''''''
    cl = clientv1()
    mosaic, = cl.get_mosaic_by_name(name).items_iter(1)
    echo_json_response(call_and_wrap(cl.get_quad_by_id, mosaic, quad), pretty)
655111
@SuppressWarnings("unchecked")
    private static void parseProperties(JSONObject modelJSON,
                                        Shape current,
                                        Boolean keepGlossaryLink) throws JSONException {
        if (modelJSON.has("properties")) {
            JSONObject propsObject = modelJSON.getJSONObject("properties");
            Iterator<String> keys = propsObject.keys();
            Pattern pattern = Pattern.compile(jsonPattern);

            while (keys.hasNext()) {
                StringBuilder result = new StringBuilder();
                int lastIndex = 0;
                String key = keys.next();
                String value = propsObject.getString(key);

                if (!keepGlossaryLink) {
                    Matcher matcher = pattern.matcher(value);
                    while (matcher.find()) {
                        String id = matcher.group(1);
                        current.addGlossaryIds(id);
                        String text = matcher.group(2);
                        result.append(text);
                        lastIndex = matcher.end();
                    }
                    result.append(value.substring(lastIndex));
                    value = result.toString();
                }

                current.putProperty(key,
                                    value);
            }
        }
    }
1367742
private Map<String, Integer> parseMinDays(JsonObject root) {
    JsonObject node = resolve(root, "supplemental", "weekData", "minDays");
    Map<String, Integer> m = new HashMap<>();
    for (String key : objectKeys(node)) {
      m.put(key, Integer.valueOf(string(node, key)));
    }
    return m;
  }
176165
private Object readLiteral() throws JSONException {
        String literal = nextToInternal("{}[]/\\:,=;# \t\f");

        if (literal.length() == 0) {
            throw syntaxError("Expected literal value");
        } else if ("null".equalsIgnoreCase(literal)) {
            return JSONObject.NULL;
        } else if ("true".equalsIgnoreCase(literal)) {
            return Boolean.TRUE;
        } else if ("false".equalsIgnoreCase(literal)) {
            return Boolean.FALSE;
        }

        /* try to parse as an integral type... */
        if (literal.indexOf('.') == -1) {
            int base = 10;
            String number = literal;
            if (number.startsWith("0x") || number.startsWith("0X")) {
                number = number.substring(2);
                base = 16;
            } else if (number.startsWith("0") && number.length() > 1) {
                number = number.substring(1);
                base = 8;
            }
            try {
                long longValue = Long.parseLong(number, base);
                if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
                    return (int) longValue;
                } else {
                    return longValue;
                }
            } catch (NumberFormatException e) {
                /*
                 * This only happens for integral numbers greater than
                 * Long.MAX_VALUE, numbers in exponential form (5e-10) and
                 * unquoted strings. Fall through to try floating point.
                 */
            }
        }

        /* ...next try to parse as a floating point... */
        try {
            return Double.valueOf(literal);
        } catch (NumberFormatException ignored) {
        }

        /* ... finally give up. We have an unquoted string */
        return new String(literal); // a new string avoids leaking memory
    }
444350
def json_loads(cls, s, **kwargs):
        
        if 'cls' not in kwargs:
            kwargs['cls'] = cls.json_decoder
        return json.loads(s, **kwargs)