Simulation Core
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

57 líneas
2.3 KiB

  1. program testjson
  2. use json_module
  3. use RedisInterface
  4. use iso_c_binding, only: c_null_char,c_char
  5. integer::n_children
  6. logical :: is_found
  7. character(len=100),allocatable::redisOutput
  8. type(json_file) :: jsonfile
  9. type(json_value),pointer :: jsonroot,pval
  10. type(json_core) :: json
  11. character(len=:),allocatable::name
  12. integer::simulationStatus,simulationSpeed
  13. ! call initConnection("config-remote.json")
  14. ! call getData(redisContent)
  15. ! print *,len(redisContent)," bytes read from redis"
  16. ! open(1,file="redisContent.json",status="REPLACE")
  17. ! write(1,"(A)") redisContent
  18. ! close(1)
  19. ! call jsoncore%initialize()
  20. ! call jsoncore%deserialize(jsonvalue,redisContent)
  21. redisOutput = '{"status":1,"speed":10}'
  22. print *,"redisOutput=",redisOutput
  23. call jsonfile%initialize()
  24. call jsonfile%deserialize(redisOutput)
  25. ! call jsonfile%get("speed",simulationSpeed,is_found)
  26. ! if ( .not. is_found ) print *,"speed Not Found"
  27. ! call jsonfile%get("status",simulationStatus,is_found)
  28. ! if ( .not. is_found ) print *,"status Not Found"
  29. ! call jsonfile%get(pval,simulationSpeed)
  30. print *,"speed=",simulationSpeed
  31. print *,"status=",simulationStatus
  32. call jsonfile%json_file_get_root(jsonroot)
  33. call json%get(jsonroot,'status',pval)
  34. call json%get(pval,simulationStatus)
  35. call json%get(jsonroot,'speed',pval)
  36. call json%get(pval,simulationSpeed)
  37. print *,"speed=",simulationSpeed
  38. print *,"status=",simulationStatus
  39. call json%destroy(jsonroot)
  40. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  41. ! call jsonfile%json_file_get_root(jsonvalue)
  42. ! call jsoncore%info(jsonvalue, n_children=n_children)
  43. ! print *,"n_children =",n_children
  44. ! call jsoncore%info(jsonvalue, name=name)
  45. ! print *,"name = ",name
  46. ! call json%initialize(allow_duplicate_keys=.false.)
  47. ! call json%create_object(p,'') !create the root
  48. ! call json%add(p,'year',1805) !add some data
  49. ! call json%add(p,'year',2000) !add some data
  50. ! call json%add(p,'value',1.0) !add some data
  51. ! call json%print(p,'test.json') !write it to a file
  52. ! call json%destroy(p) !cleanup
  53. end program testjson