{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • BaaS/Usergrid /
avatar image
0
Question by Johnson Thangaswami · Jan 04, 2019 at 11:06 PM · 160 Views baas queries

How to read a array/nested array value in a json using BaaS Query?

Hi,

I have a JSON response returned from the baas notifications as below,

{

"pathQuery": {

"applicationRef": {

"type": "application",

"uuid": "25fd9a82-c1fa-11e5-9114-0677219f14f3"

},

"pathTokens": [{

"collection": "devices",

"identifier": {

"type": "UUID",

"value": "79870948-2f50-4632-93b6-b00b16557863"

},

"ql": null

}] }

}

I would like to query the results using the pathTokens.Identifier value, so I used the sql query string like,
select * where pathQuery.pathTokens.identifier.value='79870948-2f50-4632-93b6-b00b16557863'


but it's throwing error, i also tried other possibilities but i am stuck to fetch this from an array. Can someone help me how to fetch the string from an array using sql query in API BaaS?

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

2 Answers

  • Sort: 
avatar image
0

Answer by Siddharth Barahalikar   · Jan 05, 2019 at 04:18 AM

It is been a long time since I have seen BaaS Queries here.

Since BaaS is not available for free users, I don't remember much.

Your query looks correct, what is the error you get?

Can you try querying the value of sub-properties by,

?ql=pathQuery.pathTokens.identifier.value='79870948-2f50-4632-93b6-b00b16557863'
Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Johnson Thangaswami · Jan 07, 2019 at 03:29 AM 0
Link

Thank you for replying back on this. I am getting an error message as "No entities found" after trying the select query.

Also, I can able to access the top level key:values by specifying respective id. For example from the json below,


{

"uuid": "5442d8e1-11f4-11e9-ab0e-02ffa652f380",

"type": "notification",

"state": "FINISHED",

"created": 1546807669487,

"modified": 1546807669673,

"pathQuery": {

"applicationRef": {

"type": "application",

"uuid": "25fd9a82-c1fa-11e5-9114-0677219f14f3"

},

If I query it like

"select * where uuid = '5442d8e1-11f4-11e9-ab0e-02ffa652f380'" is working

but if I traverse inside a nested block like

"select * where pathQuery.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3'" is not working.

Let me know if need more details.

avatar image Siddharth Barahalikar Johnson Thangaswami   · Jan 07, 2019 at 04:29 AM 0
Link

I'm not sure why it is not working, it is like querying sub-properties,

https://docs.apigee.com/api-baas/data-storage/querying-your-data#queryingsubproperties

?ql=pathQuery.applicationRef.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3

In your previous comment, you made a typo, you missed out applicationRef

select * where pathQuery.applicationRef.uuid= '25fd9a82-c1fa-11e5-9114-0677219f14f3

++ @Dino-at-Google @Anil Sagar @ Google

avatar image Johnson Thangaswami Siddharth Barahalikar · Jan 07, 2019 at 04:36 PM 0
Link

I've corrected the query and tried but its returning the same results as "No entities found" . I have a qn on if the ql value set to nulll inside the block, cant we not able to query it if its set to null?

"ql": null

avatar image
0

Answer by Dino-at-Google   · Jan 07, 2019 at 06:01 PM

I'm not clear on what you are doing.

It sounds like your app receives a notification from BaaS. And you want to query or parse that notification in its JSON form. Is that right? Is this not strictly a client-side issue then?

If your question is how to query an array in BaaS, then maybe this will help:

https://stackoverflow.com/questions/25297308/how-do-i-query-arrays-in-usergrid-collections

Unfortunately, there are conflicting answers there. The one consistency is that query of sub-arrays is not well supported; there's a suggestion that a query with property = 'xxx' will evaluate as true if the xxx falls anywhere within the array elements .

I suggest that you try the idea from Michael Bissell: restructure your data to make it more easily queryable.

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Johnson Thangaswami · Jan 07, 2019 at 09:45 PM 0
Link

Thank you for the prompt response on this. Let me verify and get back on this.

Follow this Question

Answers Answers and Comments

49 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

"Contains" Query Parameter Containing Two or More Words 3 Answers

Can I query BaaS directly from a request policy or only via an HTTP request? 1 Answer

Apigee BaaS push notifications metrics 1 Answer

Apigee Baas - No collections found 3 Answers

Same query at BaaS, different responses based on where call is made from 0 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges